TeX - LaTeX Asked by tnas on July 28, 2020
I want to change just the section cross-reference from roman to Arabic numbers in a paper using the IEEE template. An MWE of my problem is
documentclass[journal]{IEEEtran}
begin{document}
Section~ref{sec-test} is incorrect.
section{My Test}label{sec-test}
end{document}
The text showed in the phrase must be: “Section 1 is incorrect.” (Arabic number) But the displayed text is “Section I is incorrect.” (Roman number) The section title must remain “Section I” (Roman number).
Does someone know how to set this up?
The following minimal example updates refstepcounter
in a way that re-stores @currentlabel
using arabic
rather than Roman
specifically when the section
counter is being stepped. Both subsection
s and subsubsection
s require similar treatment and have been added as well.
documentclass[journal]{IEEEtran}
makeatletter
letoldrefstepcounterrefstepcounter
renewcommand{refstepcounter}[1]{%
oldrefstepcounter{#1}% Regular refstepcounter
ifnumpdfstrcmp{#1}{section}=0
% Update @currentlabel for section to be arabic
edef@currentlabel{arabic{section}}%
else
ifnumpdfstrcmp{#1}{subsection}=0
% Update @currentlabel for subsection to match default + arabic section counter
edef@currentlabel{arabic{section}-Alph{subsection}}%
else
ifnumpdfstrcmp{#1}{subsubsection}=0
% Update @currentlabel to match default for subsubsection + arabic for section
edef@currentlabel{arabic{section}-Alph{subsection}arabic{subsubsection}}%
fi
fi
fi
}
makeatother
begin{document}
Section~ref{sec-test} is correct.
section{My Test}label{sec-test}
end{document}
This has not been extensively tested and therefore comes with no guarantee.
Answered by Werner on July 28, 2020
The specification is quite bizarre: if a section is numbered “I” (with a Roman numeral), also cross-references should follow the scheme.
Anyway, it is quite easy to provide the required numbering scheme, because IEEEtran
detaches title numbering from the related counter's representation: for the numbering of section
it uses thesectiondis
. Thus the following works.
documentclass[journal]{IEEEtran}
renewcommandthesection{arabic{section}}
renewcommandthesectiondis{Roman{section}.}
begin{document}
Section~ref{sec-test} is incorrect.
section{My Test}label{sec-test}
end{document}
Answered by egreg on July 28, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP