{latex-kernel} is about the inner workings of the LaTeX kernel. Do not use this tag for general questions about LaTeX or {macros}.

learn more… | top users | synonyms

79
votes
2answers
5k views

What are penalties and which ones are defined?

Very often you can find solutions by changing the penalty. One is widowpenalty. However what are penalties and is there a small list of every defined penalty. There is a German site which does ...
50
votes
2answers
2k views

Documentation reference for LaTeX internal commands?

This question led to a new package: macros2e Is there a place where I can find a reference of LaTeX internal commands? For example, just a few months ago I saw an answer using \@for and today I ...
38
votes
1answer
1k views

An explanation of LaTeX's output routine

Is there a good reference for LaTeX's output routine? The documented source is confused and confusing. The authors seem confused as to why parts are the way they are and wonder if maybe things should ...
37
votes
2answers
2k views

What does \z@ do?

in parcolumns it has \z@ all over the space. I don't see it define it anywhere so I assume it is some internal command or something? I can't really make heads or tails of it though and I can't really ...
34
votes
2answers
2k views

Understanding \@ifnextchar

I understand the definitions of the \makeatletter and \makeatother commands and also \def and \newcommand somewhat. But, explained in a simple way, what is happening in the following line? ...
29
votes
4answers
1k views

What do \@firstoftwo and \@secondoftwo do?

The LaTeX kernel uses these two all over the place. For example, apparently the correct way of defining something like \ifeq{\macro 1}{\macro 2}{true}{false} is (note Martin's response: each case ...
26
votes
3answers
823 views

@tempdima, reserved@a, @tempcnta, what else?

I'm aware that some "temporary" LaTeX dimensions etc. exist. I would, however, like to know all of them. I know \reserved@a (macro), \@tempdima (dimension) and \@tempcnta (counter).
26
votes
4answers
963 views

Why does the LaTeX kernel define \usepackage *and* \RequirePackage?

The ubiquitous \usepackage command is used to load packages in the preamble of a document; the command syntax is \usepackage[<package-option-list>]{<package-list>}[<version>] ...
26
votes
1answer
208 views

Why is there no \provideenvironment?

LaTeX2e provides a \providecommand but there is no \provideenvironment which defines an environment only if it (or a macro with the same name) was not defined before. Is there a specific reason why it ...
24
votes
3answers
516 views

Saving a 100 tokens worth, is it worth it?

The LaTeX kernel defines a number of tokens that are used throughout the LaTeX source and the standard LaTeX classes. For example: \def\hb@xt@{\hbox to} This particular one is commented as: ...
24
votes
1answer
170 views

Why is the .toc file created at end document?

To create a Table of Contents (for example), LaTeX2e follows the process: Run 1 .aux file is created from scratch after \begin{document}. When processing section headers, write \addtocontents to ...
23
votes
6answers
2k views

Where can I find help files or documentation for commands like \@startsection for LaTeX?

I can't find official documentation for the \@startsection command. I already looked in: LaTeX Wikibook LaTeX: Structured document for TEX, 2008 beginLatex — a book that comes with ProTeX in the ...
23
votes
2answers
415 views

Redefining \include

A puzzling choice made by Leslie Lamport was to define \include in such a way as to issue a \clearpage before reading the file. This has been puzzling me for sometime as it is not a very good choice ...
23
votes
1answer
1k views

Check if next char is {

Using \@ifnextchar one can detect if e.g. the next Character is a [, e.g.: \@ifnextchar[% { %% code to execute if [ scanned. }{ %% code to execute if [ scanned. } However, I can’t seem to ...
23
votes
1answer
499 views

What does \@let@token do?

In source2e.pdf I've seen \@let@token used in several places, for example in the definition of \@ifnextchar: \long\def\@ifnextchar#1#2#3{% \let\reserved@d=#1% \def\reserved@a{#2}% ...
22
votes
6answers
774 views

\@ifnextchar and friends documentation

While reading this question and its answers I tried to find where, for instance, \@ifnextchar is documented. I'm afraid I couldn't... I looked in TeX: The Program and TeX for the Impatient which can ...
19
votes
1answer
501 views

Why \( and \) were not defined as robust commands in the first place?

I am aware of the difference between using \(...\) and $...$ (in moving arguments, for example), and yes, I've read the answers to this question: Are \( and \) preferable to $?). I also know the ...
18
votes
4answers
648 views

How exactly does \def\p@figure{Figure~} work?

I took this line from my thesis style and added it into my document (preceded by \makeatletter) and what it does that whenever I used \ref{figureid} instead of putting just the figure number, it puts ...
18
votes
2answers
342 views

How can I detect if I'm inside or outside of a float environment?

I am trying to detect whether I am inside or outside a float. I know the way how caption works. It uses the internal \@captype. But in the example below you see that this test failed by using ...
17
votes
3answers
487 views

What is the exact purpose of \ftype@<TYPE>?

I currently working on some float related code an saw that the standard float environments figure and table define (beside others) the macros \def\ftype@figure{1} and \def\ftype@table{2}. The LaTeX ...
16
votes
3answers
428 views

What's the use of the @compatibility condition?

All of the standard LaTeX document classes (article, book and report) declare some basic functionality and parameters based on the condition @compatibility. Here's an extract from from article.cls ...
16
votes
4answers
873 views

Understanding a \@for loop

I'm having trouble with a \@for loop. I've got a macro that takes a comma delimited list and puts each element into a row of an array. When I do this using a \@for loop, I get an extra row that I ...
16
votes
2answers
209 views

\@ifnextchar's twin in the kernel

In latex.ltx you can find \let\kernel@ifnextchar\@ifnextchar What was this needed for?
16
votes
1answer
491 views

What exactly does \@doendpe do?

Quoting from the LaTeX2e sources: [\@endparenv, \@doendpe] To suppress the paragraph indentation in text immediately following a paragraph-making environment, \everypar is changed to remove ...
16
votes
1answer
154 views

Why is there a \null in \verb?

In source2e.pdf, the definition of \verb is \def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi \bgroup \verb@eol@error \let\do\@makeother \dospecials \verbatim@font\@noligs ...
15
votes
2answers
431 views

What's the meaning of the macro `\m@th`?

I found this macro from Voss' Math mode v2.47, page 21: \makeatletter \newif\if@borderstar \def\bordermatrix{\@ifnextchar*{% \@borderstartrue\@bordermatrix@i}{\@borderstarfalse\@bordermatrix@i*}% ...
15
votes
1answer
440 views

What does \p@ mean in some code?

I have found the source code within octavo.dtx (from the octavo package) and it has some parts called \p@. I have searched throughout the document, but cannot understand what this is defined as or ...
15
votes
1answer
424 views

Are there guidelines on how to read commented sources of LaTeX packages?

I'm trying to read source2e.pdf (texdoc source2e on the command line), but I'm stumped. It seems a rather mysterious tome to me. As I understand from this answer about what arguments a command ...
14
votes
3answers
3k views

What is the default \parskip in memoir?

Everywhere the usual word is that it is 0. But that is clearly wrong, it is 0 + some rubber length. But how is that rubber length defined? In my search I found the following definition in the memoir ...
14
votes
2answers
395 views

What does the command \@dblarg in a class?

In the definition of a command appears the declaration of \@dblarg, as follows: \def\title{\@dblarg\CJ@title}. What exactly does \@dblarg do?
14
votes
1answer
457 views

What is a BANG float?

This question follows up on What is the exact purpose of \ftype@<TYPE>?. The LaTeX kernel source refers to a BANG float in the ltoutput.dtx, but there is no explanation for it. Anybody knows ...
13
votes
2answers
250 views

Why is \thepage set to \relax in a \protected@write?

In the kernel the definition of protected@write includes the setting of the \thepage to \relax. Why is this and are there other means to ensure that thepage is not expanded? \long\def ...
13
votes
1answer
512 views

Why is \input not expandable?

In latex.ltx I found \def\input{\@ifnextchar\bgroup\@iinput\@@input} where \@@inputis expandable. I would like to know if there is an expandable version of \input. The problem comes from an example ...
12
votes
2answers
194 views

\if@minipage purpose in floats

In floating environments such as the captions of figures, LaTeX has a \global\@minipagefalse, why is this necessary and what does this switch do? \long\def\@makecaption#1#2{% ...
12
votes
1answer
709 views

Use of \trivlist and \list in defining environments

I did ask a similar question a bit back here but never really had a satisfactory technical answer. Reading through the documentation of xdoc Lars Hellstrom pretty much asked the same question and ...
12
votes
1answer
241 views

Counters and their “partners”

A counter created via \newcounter{<counter>} is stored internally as \c@<counter>, just like a reference made using \label{<label>} is stored internally using \r@<label>. ...
12
votes
2answers
510 views

Is there a list of general use LaTeX kernel macros?

Here are a few cases in which one could use such a list: Is there a "prepend" version of \g@addto@macro? A "local" version? What's the most efficient way of gobbling n characters? Can I use LaTeX's ...
11
votes
1answer
381 views

Use of \@texttop and \@textbottom for vertical positioning

There are two macros defined in the LaTeX kernel named \@texttop and its opposite \@textbottom. The first is a bit of a mystery command in that in the source it is let to \relax. There is a note that ...
10
votes
2answers
162 views

What is autoload?

In the LaTeX kernel you see this often: %<*2ekernel|autoload> What does it do? There are other similar marks. Is there any documentation for these?
9
votes
4answers
153 views

Restore the original array code

The arraypackage redefines array in various ways. I was woundering if anyone had made a package containing a localized (prefixed) version of the kernel array? I have a document were we have a simple ...
9
votes
3answers
658 views

Are commands defined by \newcommand[.][.]{.} robust?

This question is from the comments at the foot of Abbreviations for AM, PM (small caps) for use within \textbf. Readers will get the remaining gist from there. With ...
9
votes
1answer
88 views

\@ifnextchar inside pmatrix?

I created a function which handles a superscript followed after the function. I do that by using \@ifnextchar^. Everything works well, except in any pmatrix environment. Why? As a quick-and-dirty ...
9
votes
1answer
299 views

When is \if@nobreak set to \iftrue or \iffalse?

In my answer to a question on page breaking, I used a private switch that the user had to set by hand to prevent tables which start just after a section from breaking (at the first line). It seems ...
9
votes
1answer
159 views

Is there a generic dummy command?

I would like to add in the title field of some bib entries a dummy command which I can redefine to force e.g. a linebreak in certain cases. I need a command which normally doesn't do anything, doesn't ...
9
votes
1answer
135 views

LaTeX2e \makebox !=\hbox?

The source2e documentation (pg. 233) when describing \makebox states: ... If wid  is missing, then pos is also missing and obj  is put in an \hbox of its natural width... This, ...
9
votes
1answer
247 views

How to illustrate and execute a MWE within another document

In Show output of a full LaTeX document I provided a partial solution to a similar question. The following code is an attempt to simulate the running of a full MWE within another document as for ...
8
votes
2answers
375 views

What exactly does \DeclareOldFontCommand and \DeclareRobustCommand do?

In the article class appears the following code related with the font selection: \DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm} \DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf} ...
8
votes
2answers
415 views

What the first argument for `\l@subsection` actually is?

Consider for example the code \makeatletter \renewcommand{\l@subsection}[2]{\@dottedtocline{2}{1.6em}{1.6em}{\S#1}{#2}} \makeatother It allows me to obtain in my table of contents records ...
8
votes
1answer
351 views

Strange behaviour with \AtEndDocument

I'm creating a document class that has draft and final versions. The final version has a front page generated by \maketitle, but in draft mode \maketitle is \let to \relax. I decided to insert a test ...
8
votes
1answer
107 views

What's the differences between the kernel commands \trivlist and \list?

LaTeX defines the two environments \trivlist and \list. Both can be used creating own environments. What exactly is the differences between \trivlist and \list?