Files
PrimeTeX/CrossRef.sty

51 lines
1.5 KiB
TeX

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PrimeTeX/CrossRef}[2025-07-09]
% Cross references
%#region
\newcommand{\refPart}[2][Part~]{#1\ref{pt:#2}}
\newcommand{\refChapter}[2][Chapter~]{#1\ref{ch:#2}}
\newcommand{\refAppendix}[2][Appendix~]{#1\ref{ch:#2}}
\newcommand{\refSection}[2][Section~]{#1\ref{sec:#2}}
\newcommand{\refSubsection}[2][Subsection~]{#1\ref{subsec:#2}}
\newcommand{\refSubsubsection}[2][Sub-subsection~]{#1\ref{sssec:#2}}
\newcommand{\refParagraph}[2][Paragraph]{#1\ref{par:#2}}
\newcommand{\refSubparagraph}[2][Subparagraph~]{#1\ref{subpar:#2}}
\newcommand{\refTable}[2][Table~]{#1\ref{tbl:#2}}
\newcommand{\refFigure}[2][Figure~]{#1\ref{fig:#2}}
\newcommand{\lblGeneral}[4][]{
\if\relax\detokenize{#1}\relax % Check if #1 is empty string.
#3{#2}\label{#4:#2}
\else
#3{#2}\label{#4:#1}
\fi
}
\newcommand{\lblPart}[2][]{
\lblGeneral[#1]{#2}{\part}{pt}
}
\newcommand{\lblChapter}[2][]{
\lblGeneral[#1]{#2}{\chapter}{ch}
}
\newcommand{\lblSection}[2][]{
\lblGeneral[#1]{#2}{\section}{sec}
}
\newcommand{\lblSubsection}[2][]{
\lblGeneral[#1]{#2}{\subsection}{subsec}
}
\newcommand{\lblSubsubsection}[2][]{
\lblGeneral[#1]{#2}{\subsubsection}{sssec}
}
\newcommand{\lblParagraph}[2][]{
\lblGeneral[#1]{#2}{\paragraph}{par}
}
\newcommand{\lblSubparagraph}[2][]{
\lblGeneral[#1]{#2}{\subparagraph}{subpar}
}
\newcommand{\lblTable}[2][]{
\lblGeneral[#1]{#2}{\caption}{tbl}
}
\newcommand{\lblFigure}[2][]{
\lblGeneral[#1]{#2}{\caption}{fig}
}
%#endregion