關於移動論證的澄清

關於移動論證的澄清

我正在閱讀latex2e有關\protect.在第 13.8 節中,它提到「表達式tabulararray環境」作為動人論證的例子。我對此感到有點驚訝。有人可以澄清這裡的意思嗎?或者說,為什麼會這樣呢?

我嘗試過嘗試,例如

\documentclass{article}
\usepackage{etoolbox}

\makeatletter

\newcommand\ae@suchthat{\mid}
\newcommand\set[1]{%%
  \begingroup
    \let\suchthat\ae@suchthat
      \{\,#1\,\}%%
  \endgroup
}

\makeatother

\begin{document}

\begin{tabular}{lc}
This & $\set{x\in X \suchthat x>42}$
\end{tabular}

\end{document}

但這裡似乎沒有問題。我對脆弱與堅固有什麼誤解?

答案1

手冊應提及“ and@中的-表達式”,以與 Leslie Lamport 的官方手冊保持一致。這是一個例子:tabulararray

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{tabular}{l@{ \resizebox{2mm}{!}{$x$} }l}
A & B \\
C & D
\end{tabular}
\end{document}

由於移動參數中的脆弱命令,最終會出現典型的錯誤訊息:

! Use of \@array doesn't match its definition.
\@ifnextchar ... \reserved@d =#1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...
l.5 ...in{tabular}{l@{ \resizebox{2mm}{!}{$x$} }l}

如果我們使用的話,\protect\resizebox就不會出現錯誤。

引自“LaTeX,文件準備系統”,第 168 頁:

C.1.3 脆弱命令

命令分類為強壯的脆弱的。 [...]以下是所有帶有移動參數的命令和環境:

  • [...]

  • 一個@inarraytabular環境。 (雖然@不是命令,但@- 表達式中的脆弱命令必須\protect像在移動參數中一樣進行 'ed。)

相關內容