在章節標題中使用小型大寫字母

在章節標題中使用小型大寫字母

簡短的搜尋沒有找到答案,所以我發布這個問題:

有沒有辦法讓小型大寫字母在(子子...)部分標題中正確顯示?

我的問題特別在於以下程式碼:

\documentclass{article}
\newcommand*{\matlab}{\textsc{matlab}}

\begin{document}
 \section{\matlab}}
\end{document}

它不是在標題中生成小寫的 MATLAB,而是生成普通文本 - “matlab”,\textsc{}newcommand*{}{}.

它實際上不會產生錯誤或警告並進行編譯,但不會給我所需的輸出。

有人知道解決方法/解決方案嗎?

答案1

您發現的是 Computer Modern 字體系列不具有粗體/小型大寫字母粗細/形狀組合。要恢復小型大寫字母字串的「正常」權重,您需要在其前面添加一條\mdseries指令。

在此輸入影像描述

\documentclass{article}
\newcommand*{\matlab}{\textsc{matlab}}
\newcommand*{\altmatlab}{{\mdseries\matlab}} % note the double pair of curly braces
%%% "\newcommand*{\altmatlab}{\textmd{\matlab}}" works too...
\begin{document}
 \section{A title that contains ``\matlab'' as a string}
 \section{A title that contains ``\altmatlab'' as a string}
\end{document}

其他字體系列(例如 Times Roman)確實具有粗體/小型大寫字母組合。如果您要使用這些字體系列之一,那麼\matlab在節標題中使用基本巨集就可以了。

答案2

也可能:

\documentclass{article}

\newcommand*\matlab{{\normalfont\textsc{matlab}}}

\begin{document}

  \section{A title that contains ``\matlab'' as a string}

\end{document}

相關內容