1

I find it difficult to find the definition of commands starting with @. Where and how is \@nobreaktrue defined?

Mico
  • 506,678

1 Answers1

3

TeX has a build in primitive \show to show the meaning of a command sequence. For example

\show\TeX
\bye

in plainTeX writes:

> \TeX=macro:
->T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emX.
l.1 \show\TeX

to the terminal and the log-file.

But for LaTeX commands, that has been defined robust, this only show, something not very useful:

\show\pagebreak
\documentclass{article}
\begin{document}
\end{document}

results in the terminal (and the log-file) output:

> \pagebreak=macro:
->\protect \pagebreak  .

Because of this, LaTeX from release 2020-10-01 has a new command \ShowCommand (see ltnews32.pdf).

\ShowCommand\pagebreak
\documentclass{article}
\begin{document}
\end{document}

shows:

> \pagebreak=robust macro:
->\protect \pagebreak  .

> \pagebreak =\long macro: ->@testopt {@no@pgbk -}4. <argument> \pagebreak

Which is more useful.

Note: The <argument> \pagebreak in the output above does not mean, that \pagebreak is a argument of \pagebreak, but that the \ShowCommand has been run with argument \pagebreak. I'm explaining this, to avoid misunderstanding the output. Real arguments would be shown as #1 etc. before the ->.

To show a command sequence starting with @ you have to use \makeatletter…\makeatother:

\makeatletter
\ShowCommand\@nobreaktrue
\makeatother
\documentclass{article}
\begin{document}
\end{document}

writes to the terminal (and into the log-file):

> \@nobreaktrue=macro:
->\global \let \if@nobreak \iftrue .

Because \@nobreaktrue is not robust,

\makeatletter
\show\@nobreaktrue
\makeatother
\documentclass{article}
\begin{document}
\end{document}

has the same output.

BTW: To find out, where a definition has been done, you can only move the \ShowCommand. In the examples above all definitions can be found in the used formats. For example for \ShowCommand\section before \documentclass you would get \section=undefined. So you would know, that it is not a command of the LaTeX format. After loading the class, you would get another output and you'd know, that it is defined either in the class itself or a package required by the class.

To find a definition you could also search over the whole TEXMF tree, e.g., using grep -R '\\@nobreaktrue' /usr/local/texlive/2022/texmf-dist/tex/* in a Linux/Unix terminal. However, this would show not only the definition but also every usage. So you would need to restrict the search results more. In case of \@nobreaktrue doing

grep -R '\\def\\@nobreaktrue' /usr/local/texlive/2022/texmf-dist/tex/*

would result in:

/usr/local/texlive/2022/texmf-dist/tex/latex/base/latex.ltx:\def\@nobreaktrue {\global\let\if@nobreak\iftrue}
/usr/local/texlive/2022/texmf-dist/tex/latex-dev/base/latex.ltx:\def\@nobreaktrue {\global\let\if@nobreak\iftrue}

But, i.e., for \@footrue usually searching for a regular expression like \\newif *\\if@foo[^@a-zA-Z] is the better choice.

cabohah
  • 11,455