I'm wondering how to get a reference to a sub(sub)section that is
different from the number printed on the section header. More
specfically, I need a reference like "section 2a.5" from "section~
\ref{sss:my-subsubsection}" whereas "\subsubsection{Tertiary header}"
prints "5) Tertiary header" in the style I'm using.
I'm using a LaTeX template and style file provided by a journal
publications office. But, the style file is far from complete. The
journal uses the following section numbering system: 1, 2, 3, . . . ,
for sections, a), b), c), . . . , for subsections, and 1), 2),
3), . . . , for subsubsections. When you refer to a subsubsection "5"
under subsection "a" under section "2", for example, you are expected
to write "section 2a.5". The \ref command from the provided style
file, however, just prints "5", which isn't acceptable.
I tried modifying \thesubsubsection, which gave the correct reference
but a wrong subsubsection heading. I can see that the \newlabel
commands in the .aux file determines what's printed for \ref, but I
couldn't find how to change what's written in \newlabel.
Regards,
Ryo
OK, I've come up with a hack. Since I know very little of plain TeX
and internal working of LaTeX, this solution can be very fragile,
inelegant, or simply incorrect:
\makeatletter
\def\refstepcounter#1{\stepcounter{#1}%
\def\stringSubS{subsection}\def\stringSubsubS{subsubsection}\def
\stringArg{#1}%
\protected@edef\@currentlabel
{%
\ifx\stringSubS\stringArg
\noexpand\thesection\csname p@#1\endcsname\csname
the#1\endcsname
\else
\ifx\stringSubsubS\stringArg
\noexpand\thesection\thesubsection.\csname p@#1\endcsname
\csname the#1\endcsname
\else
\csname p@#1\endcsname\csname the#1\endcsname
\fi\fi
}%
}
\makeatother
Regards,
Ryo
P.S. Is there "elseif", "elsif", or "elif" in TeX? Or a case/switch
statement?
> On May 30, 2:32 am, Ryo <fu...@hawaii.edu> wrote:
> [. . .]
>> I'm wondering how to get a reference to a sub(sub)section that
>> is differentfrom the number printed on the section header. More
>> specfically, I need a reference like "section 2a.5" from "section~
>> \ref{sss:my-subsubsection}" whereas "\subsubsection{Tertiary header}"
>> prints "5) Tertiary header" in the style I'm using.
The standard classes don't support such customizations, but other
classes do. Here is an example for the scrartcl class:
\documentclass[pagesize=auto, version=last]{scrartcl}
\newcommand*{\formatsection}{\arabic{section}}
\newcommand*{\formatsubsection}{\alph{subsection}}
\newcommand*{\formatsubsubsection}{\arabic{subsubsection}}
\renewcommand*{\thesection}{\formatsection}
\renewcommand*{\thesubsection}{\thesection\formatsubsection}
\renewcommand*{\thesubsubsection}{\thesubsection.\formatsubsubsection}
\renewcommand*{\othersectionlevelsformat}[3]{\csname format#1\endcsname)\enskip}
\begin{document}
\section{ab}
\subsection{cd}
\subsubsection{de}
\label{test}
section~\ref{test}
\end{document}
> P.S. Is there "elseif", "elsif", or "elif" in TeX? Or a case/switch
> statement?
No.
--
Change “LookInSig” to “tcalveu” to answer by mail.