# Tag Info

120

Penalties are the main value that TeX tries to minimise when line or page breaking, They may be inserted explicitly (\penalty125 means that the penalty for breaking at that point is 125). Some penalties are built in to the TeX system and inserted automatically, LaTeX for example sets these default values for built in penalties \linepenalty=10 the penalty ...

71

latex.ltx says \newdimen\z@ \z@=0pt % can be used both for 0pt and 0 so as it says it is short (and efficient) way of getting 0. You should always have a copy of the latex source file latex.ltx in a text editor window while reading package code:-), or perhaps, if you prefer, the typeset version of that, without the comments being removed, source2e.pdf, ...

58

I now compiled such a document listing all internal macros of LaTeX2e which are also useful for package authors. The work title is "List of internal LaTeX2e Macros useful to Package Authors" and I'm planning to release it on CTAN 'soon' (e.g. as 'macros2e') when its out of the beta stage. The beta release can be found on my website. There is also a feedback ...

46

\z@ is a LaTeX “constant” that's defined to be zero. Package developers can use it to assign or test against the value 0 and it can also replace a length of 0pt. Similar constants are \@ne (one) \tw@ (two) and so on. Due to the @ they can only be used in packages or between \makeatletter and \makeatother.

45

This is a very important function in the LaTeX kernel. The macro \@ifnextchar takes three argument. The first one should be a single token, usually [ but not necessarily. When the input stream has the following tokens \@ifnextchar<token>{<true>}{<false>} TeX will look at the next token (skipping spaces) and compare it to the ...

44

\@ifnextchar is a LaTeX conditional that peeks ahead at the following character. So, \@ifnextchar[ looks ahead to see if the following character in the input stream is a [ (opening left bracket). If this is true, then it executes the immediately following token, otherwise, it skips it and executes the token following that. The first token, executed upon a ...

43

Penalties are used by TeX for controlling the line and page break routines. Some of them are inserted implicitly, others can be added by the user (usually via macros). A penalty issued in horizontal or math mode will influence line breaking, one issued in vertical mode will influence page breaking decisions. The list of "implicit penalties" can be found in ...

41

The output routine is called either by TeX's normal page-breaking mechanism, or by a macro putting a penalty of < or = -10000 in the output list. These large penalties communicate with the OTR. For example a penalty of -10001 is a clearpage, whereas a -10004 is a float insertion etc. Information on LaTeX output routine is very hard to find - and guessing ...

32

The actual command, including its formal definition posted by @JoshLee is contained in the LaTeX 2e source, section 61.2 Sectioning (p 283). It forms part of ltsect.dtx, the bundle containing all sectioning commands for LaTeX. It even includes a pseudo-code interpretation of the actual macro. Here is an extract: The ...

31

If you have a look in the tex\latex\tools\ directory, you'll see some other odd-looking files as well: h.tex, e.tex, q.tex, r.tex and s.tex. These are all single letter responses you can give when LaTeX prompts you for a filename. Consider this document: \documentclass{article} \begin{document} \input{foo} \end{document} Assuming that foo.tex doesn't ...

29

The 'manual' for LaTeX is LaTeX: A Document Preparation System by Leslie Lamport. This is as you observe a commercial book and one is therefore expected to visit a bookshop or library to obtain a copy. As you might also note, much of the same information as in Lamport's book is available in one or another free form (and other commercial offerings). To ...

29

You are missing two very important \expandafters. The normally used, "correct" code is: \def\ifeq#1#2{% \ifx#1#2\relax \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi } The difference to a macro which uses #3 and #4 is that the if-statement is fully processed before the first or second of the next two arguments is processed. This ...

27

This is the kind of question that is fairly difficult to answer after 20 years. But basically because it was not considered so important. One has to remember that the implementation of 2e was guided by space and speed restriction, So initially we spend an enormous amount of time optimizing the kernel for speed and space. 2e introduced a lot of new code ...

27

The LaTeX kernel allocates some scratch registers and defines a scratch conditional. The complete list is \newcount\@tempcnta \newcount\@tempcntb \newif\if@tempswa \newdimen\@tempdima \newdimen\@tempdimb \newdimen\@tempdimc \newbox\@tempboxa \newskip\@tempskipa \newskip\@tempskipb \newtoks\@temptokena Notice that for the first two \newcount is used, ...

25

The use of scratch registers and macros in TeX/LaTeX date back to the time when it was absolutely essential to conserve memory consumption, because TeX's memory (both in terms of token/macro memory as well as number of available registers) was very limited and one could easily run out of space just by loading a few packages on top of the main format. Traces ...

25

Any command may be used as an environment, and if surrounding large blocks of text it is often convenient, so {\small zzz\par} and \begin{small}% zzzz \end{small} are more or less equivalent. Note however that unlike \small, spaces after \begin{small} are not dropped due to normal TeX tokenization rules. Also you almost always need a \par or blank ...

24

\@ifnextchar\bgroup See the definition of \input in the kernel: \def\input{\@ifnextchar\bgroup\@iinput\@@input} where \@iinput is able to cope with \input{file} and \@@input is an alias for the primitive \input so \input file will be processed as well. \@ifnextchar has three arguments: (1) the token to be looked for, (2) what to do if it's found, and ...

24

This is abbreviated notation for a 1pt dimension, as included in latex.ltx and therefore common to all LaTeX documents: \newdimen\p@ \p@=1pt % this saves macro space and time \newdimen\z@ \z@=0pt % can be used both for 0pt and 0 As such, you can use it in calculation with dimensions, such that 60\p@ translates to 60 times 1pt, or 60pt. In a similar ...

23

Actually, the “LaTeXbook” (properly “LaTeX. A Document Preparation System”, by Leslie Lamport) endorses the use of such environments: at the end of page 27 we find: Every declaration has a corresponding environment of the same name (minus the \ character). Typing \begin{em} ... \end{em} is equivalent to typing {\em ... }. In particular, the ...

22

The LaTeX kernel (latex.ltx) saves a few primitives with new names: these are all from TeX90 as the kernel itself does not use any primitives from e-TeX or later. Two of these are token registers, saved as \frozen@...: \everydisplay saved as \frozen@everydisplay \everymath saved as \frozen@everymath The other 'renamed' primitives are all saved as \@@...: ...

22

Let's assume you have \include{fileA} \include{fileB} If there is no \clearpage when fileA ends and TeX starts reading fileB, there might be a \write relative to fileA pending and it will get lost: the \write commands relative to \label are performed at shipout, not immediately. When the next shipout occurs, the fileA.aux file will have already been ...

22

It was when the code was written, but is not now (in my opinion). The current LaTeX2e kernel was released in 1992 and carries forward a lot of material from LaTeX2.09. Even with these optimisations and the old 'autoload' system, there were a lot of systems that LaTeX was too big for on release. So looked at in the early 1990s this was entirely sensible. I'd ...

21

\@let@token is assigned by \futurelet to the next token after the \@ifnextchar, i.e. it is the next character. The \futurelet\@let@token\@ifnch code means "assign the next token to \@let@token and then process \@ifnch". Inside \@ifnch the \@let@token macro is tested if it is equal to the (first token of the) first argument of \@ifnextchar, i.e. \reserved@d ...

21

A macro is any control sequence (or active character) defined with \def, \gdef, \edef or \xdef. TeX macros support up to nine arguments, which contradicts your statement about it not having the notion of arguments to control sequences. The most common usage of arguments is in the “undelimited” form; say that you do \def\foo#1{--#1--} so \foo takes an ...

20

You can use any LaTeX command defined by \newcommand and wrap a \begin{}...\end{} pair around it, however, it's not recommended, since this is not an environment. The interesting thing is, however, that grouping works anyway, but this is consequence of \begin...\end. There are no fontsize environments like \begin{small} etc, as there aren't ...

20

Since the fixltx2e package ends with \MakeRobust$$\MakeRobust$$ \MakeRobust$\MakeRobust$ \MakeRobust\makebox \MakeRobust\savebox \MakeRobust\framebox \MakeRobust\parbox \MakeRobust\rule \MakeRobust\raisebox it is probably safe to say that it was simply a mistake that was left around because the kernel can't change at this point. It's also worth ...

20

\p@ is a LaTeX2e kernel dimension, equal to 1 pt. It is used as this saves some tokens in the kernel, and also makes it possible to write thinks like 0\pt, which TeX interprets as 0 times 1 pt. So written out 'long hand' the definition is '1pt'. (That token-saving was really important when LaTeX2e was written: \p@ is one token, 1pt is three. Today, it is ...

20

There is \pdftexbanner primitive which will give you that message (works for both pdftex and luatex), but xetex don't seem to have a similar banner primitive.

20

I guess texdoc source2e is the answer to many of your questions. Both the macro's you mentioned are discussed in the manual, which is basically a documented source of LaTeX2e. As for learning these commands, it's reading existing packages, reading the documentation and reading tex.stackexchange.com. At least it is for me :).

19

fixltx2e, etex, morefloats, latexrelease are all affected to some extent. At each LaTeX release there is a one or two page newsletter describing the main changes (ltnews 22 and 23 for the 2015/01/01 and 2015/10/01 releases, respectively) these days we bundle them as one file texdoc ltnews or ltnews.pdf from CTAN. As detailed in ltnews 23 fixltx2e is ...

Only top voted, non community-wiki answers of a minimum length are eligible