\documentclass{book}
\usepackage{nth}
\begin{document}
\nth{3} is not the same as $\nth{3}$
\end{document}
此代码对于数字来说效果很好。现在,如果我想在参数中传递 III ,我该怎么做?
我希望输出为 III(倾斜-->我使用数学模式实现了这一点)rd(上标)
答案1
如果我正确理解了你的问题,那么(正如问题的评论所建议的那样)我认为在英语中写这样的内容不是标准做法III^{rd}
,更不用说使用斜体字体了,我建议你不要这样做。
话虽如此,实现目标的一种方法是定义一个类似于的命令\nth
,但将参数转换为(大写)罗马数字。 三个选项:一,使用罗马字体表示完整表达式;另一个使用倾斜字体表示数字,使用罗马字体表示上标;第三个,使用倾斜字体表示完整表达式:
\documentclass{book}
\usepackage[super]{nth}
\def\Rnth#1{{% First print number:
\expandafter\nthM \MakeUppercase{\romannumeral\number#1}\relax
\nthscript{%
\ifnum#1\nthtest0 th\else % negatives are all ``th'' (depending on \nthtest)
\expandafter \nthSuff \expandafter 0\number\ifnum #1<0-\fi#1\delimiter
\fi
}}}
\def\RSnth#1{{% First print number:
\expandafter\nthM \slshape\MakeUppercase{\romannumeral\number#1}\kern1pt\relax
\nthscript{%
\ifnum#1\nthtest0 th\else % negatives are all ``th'' (depending on \nthtest)
\expandafter \nthSuff \expandafter 0\number\ifnum #1<0-\fi#1\delimiter
\fi
}}}
\def\Rsnth#1{{% First print number:
\expandafter\nthM \slshape\MakeUppercase{\romannumeral\number#1}\kern-1pt\relax}
\nthscript{%
\ifnum#1\nthtest0 th\else % negatives are all ``th'' (depending on \nthtest)
\expandafter \nthSuff \expandafter 0\number\ifnum #1<0-\fi#1\delimiter
\fi
}}
\begin{document}
\Rnth{3} is not the same as \nth{3}.
\Rnth{2} is not the same as \nth{2}.
\RSnth{3} is not the same as \nth{3}.
\RSnth{2} is not the same as \nth{2}.
\Rsnth{3} is not the same as \nth{3}.
\Rsnth{2} is not the same as \nth{2}.
\end{document}
如果希望数字为斜体,请在相应的定义中替换\slshape
为。\itshape
在我看来,使用倾斜字体的两个选项看起来真的很丑;请考虑不要使用它们。