I find it difficult to find the definition of commands starting with @. Where and how is \@nobreaktrue defined?
-
2your title asks about one specific command but the body asks about all commands starting @ . in package @ is a letter so asking about all commands starting @ is like asking about all commands starting k and has no real answer – David Carlisle Feb 21 '23 at 07:43
-
@DavidCarlisle ok, i improved explaining of question – Мақсат Feb 21 '23 at 07:47
-
4I'll mark macros - Where do I find out how a command/environment is defined? - TeX - LaTeX Stack Exchange as answering this one because the first answer there points out source2e, which solves this question. – user202729 Feb 21 '23 at 08:46
1 Answers
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.
- 11,455