\LaTeX 標誌中的指令有什麼作用?

\LaTeX 標誌中的指令有什麼作用?

我正在嘗試以與徽標類似的方式排版單字\LaTeX。我已經找到了徽標的代碼(在 MWE 中給出),但它使用了許多我以前從未見過的命令,例如\z@(根據谷歌搜索為零?),以及T\vbox to \ht我所使用的奇怪語法()不習慣。

我試圖理解命令的每一步,包括語法,以及為什麼這樣做。

如果有人覺得有必要嘗試程式碼,可以使用 MWE:

\documentclass{standalone}
\begin{document}
\makeatletter
    L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.15em\TeX
\makeatother
\end{document}

答案1

\makeatletter %% access private macros
L%% print an L
\kern -.36em%% add a negative kern
{%% open a group
  \sbox \z@ T%% load box 0 with a T
  \vbox to\ht \z@ {%% start a vertical box as high as box 0
    \hbox {% start a horizontal box
      \check@mathfonts%% ensure the math fonts sizes are set up at the current font size
      \fontsize \sf@size \z@%% use the established font size for sub/superscripts
      \math@fontsfalse%% don't bother setting up all the math fonts for the new current size
      \selectfont%% select the font
      A%% print an A
    }%% finish the horizontal box
    \vss%% fill up the stated height
  }%% finish the \vbox
}%% end the group
\kern -.15em%% add a negative kern
\TeX%% print the TeX logo
\makeatother%% no more private macros allowed

一些筆記。

\sbox\z@ T完全等價於\sbox{0}{T};程式碼被減少到最小數量的標記,因為在開發 LaTeX2e 時,電腦記憶體非常稀缺。定義中儲存的程式碼\LaTeX是三個標記,而\sbox{0}{T}has 是七個。

a\vbox和 an\hbox是什麼可以在 TeX by Topic 中找到(可以在任何 TeX 發行版texdoc texbytopic或 CTAN 上免費獲得)。

\check@mathfonts確保數學字體設定為當前大小;通常這僅在數學公式啟動時完成。此指令特別定義\sf@size第一級子/上標的字體大小。該巨集\selectfont設定當前字體;我們\math@fontsfalse告訴它不要做設定數學字體的必要工作,因為我們只想按請求的大小列印 A,而不是用數學排版任意文字。

\vss與 相同\vspace{0pt plus 1fil minus 1fil},因此它是一個無限伸縮的空間,它將推動\hbox包含 A 的 與 的頂部齊平\vbox。因此,A 的頂部將與 T 的頂條高度相同(也可能是 L 的頂部)。

A\kern類似於\hspace,但不可拉伸或收縮。在這些地方它是首選,因為它不能用作換行點(除非後面有一個跳過)。

的定義\TeX更簡單:E 向下移動並套用一些緊排。


正如芭芭拉在評論中指出的那樣,這個定義針對電腦現代字體進行了非常仔細的研究。其他字體可能會產生不太好的結果。該metalogo套件嘗試“抽象”間距,因此徽標可以以最小的麻煩適應其他字體(但需要進行一些嘗試才能獲得正確的參數)。

相關內容