source2e.pdfより

source2e.pdfより

の定義は\@setfontsize次のようになります( の出力\makeatletter\meaning\@setfontsize

\@nomath#1\ifx\protect\@typeset@protect\let\@currentsize#1\fi\fontsize{#2}{#3}\selectfont
  • \@nomath数式モードでこのマクロを呼び出すと警告が発行されます。source2e を参照してください。
  • \let\@currentsize#1私のsource2eにはない。私のバージョン(v. 2017/01/01 パッチレベル1)には\@currsize#1
  • \fontsize{fontsize}{baselineskip}

\@typeset@protect(の出力を\makeatletter\meaning\@typeset@protect)明らかにすると、 が生成されます\relax

source2e.pdfより

\@setfontsize が堅牢性を維持することを保証するために、\protect が \@typeset@protect と異なる場合にはこの割り当てを省略します。

  • それはいつですか?
  • \relaxこれはいつ、どのような目的で他のものに設定されるのでしょうか?
  • ちなみに「頑強であり続ける」というのは興味深い表現だ

答え1

\documentclass{article}

\begin{document}

\typeout{\large abc}

\end{document}

ログを生成する

\relax \fontsize {12}{14}\selectfont abc

これは特に興味深いものではありませんが、 と同等のコードであり、実際のアプリケーションでファイル\largeに書き込まれると、読み戻されたときに意図したとおりに動作します。auxtoc

定義を変更して\ifx\protect\@typeset@protectテストを削除すると、その効果はかなり劇的になります。

\documentclass{article}

\begin{document}


\makeatletter
\def\@setfontsize#1#2#3{\@nomath#1%
%    \ifx\protect\@typeset@protect
      \let\@currsize#1%
%    \fi
    \fontsize{#2}{#3}\selectfont}

\typeout{\large abc}

\end{document}

生産する

! TeX capacity exceeded, sorry [input stack size=5000].
\@nomath ...e \@font@warning {Command \noexpand #1
                                                  invalid in math mode}\fi 
l.13 \typeout{\large abc}

!  ==> Fatal error occurred, no output PDF file produced!

基本的に、このテストはフォント サイズ コマンドが脆弱ではなく堅牢であることを確認します。

関連情報