Hot answers tagged

27

Not any character or action is available from a keyboard input as such an escaping to the 'TeX' system is necessary to typeset certain symbols or trigger actions -- in order to distinguish the text "foo" from a an action (call it macro etc.) named "foo" as well a certain method is necessary. D.E. Knuth designed \ to be \ the “escape char” and is used to ...


13

There are syntactical reasons. LaTeX has the concept of environments, not present in plain TeX. The environment document is the outer environment of the document contents. The setup/configuration of the document is separated from the actual document contents and this is done in the preamble before the environment document starts. The preamble loads the ...


12

I did more exploration about this problem and I hope that I have an answer. First, a short summary from TeXbook terminology. The main vertical list is split to two parts by imaginary horizontal line: current page above this line and recent contributions below it. The current page has the c value (cost) calculated at all possible break points but recent ...


11

Let's look at how \enddocument is defined (see latex.ltx, the LaTeX "kernel"): \def\enddocument{% \let\AtEndDocument\@firstofone \@enddocumenthook \@checkend{document}% \clearpage \begingroup \if@filesw \immediate\closeout\@mainaux \let\@setckpt\@gobbletwo \let\@newl@bel\@testdef \@tempswafalse ...


8

The main vertical list is split into two parts: the current page and the recent contributions. At certain times, TeX exercises the page builder, that is, moves the items in the recent contributions to the current page: when a penalty is added to the main vertical list (which could be from \vadjust); after the closing brace of an \insert; a box is added to ...


7

Two excellent answers have already been given, that explain in detail what happens and why: I would just like to add a few remarks, and corroborate the analysis with evidence coming from appropriate tracing commands. I will use the following diagnostic program: % !TEX TS-program = pdftex \showboxbreadth = 1000 \showboxdepth = 10 \output={% ...


5

While it seems that there is no difference in semantics (but I'm still waiting for answers here), there seems to be a small but consistent difference in performance. First, \the consists of 4 characters and \number of 7, so you can type it almost twice as fast! ;-) Seriously, \the\numexpr seems to be 10 - 15% faster than \number\numexpr. As it's not ...


5

Concerning the line \hbox to \hsize{abc} you are actually right in your statement I am expecting the abc to be glued with maximum stretched glue Unfortunately, you can't see the glue, because glue is applied between words, not between letters of a word. The space between the letters is given by the font settings, namely kerning which is not allowed ...


4

Since we have, in plain.tex 508 \def\lq{`} \def\rq{'} (line number added for reference), you can just type \csname\rq\endcsname that will expand \rq to ' and build a control sequence token out of this. You can't use \expandafter that way: \expandafter\\lq is four tokens \expandafter•\\•l•q (the bullet just separates tokens), so you are trying ...


3

You can use expl3; the \strcompare macro is just a user level version of the expandable internal function \str_if_eq:nnTF. \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \cs_new_eq:NN \strcompare \str_if_eq:nnTF \ExplSyntaxOff \begin{document} start\par \strcompare{abc}{def}{OOPS}{OK}\par \strcompare{abc}{abcd}{OOPS}{OK}\par ...


2

The term “glue” might be misleading. It is not something that's used to glue letters together, which isn't needed, but rather something that spaces things from one another. Glue can be rigid or flexible; flexibility can be in the amount of allowed stretch or shrink (or both, of course). When TeX is ordered to fill with text some amount of horizontal space, ...


1

I've read that with \usepackage{pdftexcmds}, you can use \pdf@strcmp but haven't checked if it works in this case. Alternatively, the code below defines \expandable@if@equal{str1}{str2}{if-case}{else-case}, which can be used as follows: \makeatletter start% \expandable@if@equal{abc}{def}{OOPS}{OK}% \expandable@if@equal{abc}{abcd}{OOPS}{OK}% ...



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