# Tag Info

7

Many syntax errors in a (La)TeX document are simple mistakes due to forgetting a $or a backslash, say a & or$ instead of \& and \$in text. Other common errors are due to mistyping a command or forgetting a brace. TeX is quite good in getting back in sync when such errors happen: a misplaced$ or a missing one can be catched and most of the times ...

18

this was addressed by Knuth in a q&a session in st. petersburg, florida, published in tugboat: - TUG'95: Questions and Answers with Prof. Donald E. Knuth, pp.18 (bottom of column 2) - 20; the session was republished in Digital Typography, with the relevant question starting on p.594. the page-breaking problem was also the subject of Michael Plass' ...

18

It was proved by Plass, that the page breaking problem can be NP-complete. Computers were about 10^4 times slower than nowadays, so it was a problem.

4

Here is how you can have your \starredcommand with arguments \documentclass{article} \usepackage{amsmath} \usepackage{mathrsfs} \makeatletter % Following 3 lines thanks to Prof. Enrico Gregorio, from: % http://tex.stackexchange.com/questions/42318/ % removing-a-backslash-from-a-character-sequence \begingroup\lccode\|=\\ ...

8

A quick attempt with xparse: \documentclass{article} \usepackage{xparse,mathrsfs} \NewDocumentCommand\optional{mO{}mm} {% \NewDocumentCommand{#1}{o#2} {\IfNoValueTF{##1}{#4}{#3}}% } \NewDocumentCommand\starredcommand{O{s}mmm} {% \NewDocumentCommand{#2}{#1} {\IfBooleanTF{##1}{#4}{#3}}% } \optional{\foo}{F(#1)}{F} \optional{\baz}[m]{Baz with ...

0

Below there is an alternative. \Tokens remains local. \documentclass{article} \def\ta{Hello} \def\tb{ World. } \def\tc{How are you?} %\def\Tokens{\ta\tb\tc} \begin{document} \begingroup \def\Tokens{\ta\tb\tc}% or like above with def \let\ua=\tc \let\ub=\tb \let\uc=\ta \ua\ub\uc---\par \expandafter\endgroup\Tokens \show\Tokens \end{document}

4

In some situations TeX assumes, that some text is misspelled. Sometimes the expected way of a correction is removing problematic command, sometimes -- adding additional expressions. E.g. if you type only \sin(x), TeX assumes, that you lost a dollar sign, because \sin must appear inside math.

1

To answer my own question: I found a program called tie in CTAN, which you can use to fully merge change files into the original WEB file. Once you've done this you can use weave to convert to a .tex, .pdf file of the combined code.

4

The other answers have described the difference between kerns and skips (glue) however to pick up on one comment in your question. \mkern (like \kern) does not parse and silently accept plus and minus glue stretch expressions. If given a skip register it will accept that and silently discard the stretch components, and use the natural length, but if passes a ...

3

You can use the package linegoal. Please note you need two compilation steps. \documentclass[a4paper]{article} \usepackage{showframe} \usepackage{linegoal} \begin{document} Text Text Text \rule{\linegoal}{2pt} Text \the\linegoal More more text more textText \the\linegoal \end{document}

10

There is no variable where the size used for \hfill is used. Without taking \parindent into account, for simplicity, your first example is equivalent to saying \hbox to\hsize{a\hfill b\hfill c\hfill d} TeX measures the “natural width” of the box as if it had been \hbox{a{}b{}c{}d}, since the natural width of \hfill is zero. Then it computes the ...

10

The difference between \mkern and \mskip is only that the latter can have stretchability and shrinkability. For instance, the spacing between an ordinary symbol and a relation symbol is obtained by \mskip\thickmuskip (TeX automatically does it); conversely \joinrel, which is internally used for joining dashes in order to build a longer arrow, is ...

4

The key to this exercise is to properly deal with boxes. In the MWE below, I create boxes that match the widths of the corresponding elements in the first line, yet prints something different with some altered alignment. All of this is made possible by means of the command \makebox[<width>][<alignment>]{<stuff>}: \documentclass{article} ...

9

I quote from TeX By Topic, which is freely available via texdoc texbytopic: The \kern command specifies a kern item in whatever mode TeX is currently in. A kern item is much like a glue item without stretch or shrink. It differs from glue in that it is in general not a legal breakpoint. Thus in .. text .. \hbox{a}\kern0pt\hbox{b} TeX will not ...

11

TeX has the concept of an invalid character (a byte sequence with \catcode 15) so if TeX is being set up with any 8 bit character having this catcode then obviously a format doing so will choke on a file containing this character. By default (and probably for historical reasons) plain TeX and LaTeX have one character of that nature: "delete" (which is ^^K), ...

8

You need something to terminate the run. If you make every non letter catcode 9 (ignored) you can't use a control sequence but you can use end-of-file, as long as you use etex (pdftex xtetex) etc, this doesn't work with classic tex. My test file had nulls and bells control-@ and control-g etc in the stream but the system doesn't seem to allow me to cut and ...

18

There is no byte sequence that may not occur somewhere in a file (obviously there are restrictions at the beginning of a file before you change catcodes) however there are sequences of character tokens that may never occur. Specifically relating to white space trimming and normalisation at the end of lines, white space at end of line is stripped at a very ...

-2

I guess your only "legal" option would be scanning the paper original and create your own pdf, for personal use; that could be considered the equivalent to make a photocopy of a book you own for taking notes, underline, etc.

1

TeX has the option of a set of formatting macros called a format. Plain TeX is one of these formats, LaTeX is another, ConTeXt is a third. So in that sense LaTeX is just a layer of helper code over TeX, like a library in a programming language. As far as I understand it (and many here do better than I), prior to pdftex the latex executable was a version ...

1

LaTeX is a link to pdftex voss@shania:~> ls -l /usr/local/texlive/2012/bin/x86_64-linux/latex lrwxrwxrwx 1 voss 1000 6 12. Apr 22:44 /usr/local/texlive/2012/bin/x86_64-linux/latex -> pdftex Inside pdftex it knows that it was called as latex or pdflatex. The reason why it loads the format LaTeX, which is more or less loading under pdftex the file ...

1

Leslie Lamport, in his seminal work, LaTeX, A Document Preparation System, User Guide and Reference Manual, Addison-Wesley, 1985, pp.6, describe exactly how LaTeX and TeX are related: LaTeX is your typographic designer, and TeX is its typesetter.

8

All the programs in the TeX series (TeX by itself, but also METAFONT and all the auxiliaries) are written in WEB, but to ease the translation, D. E. Knuth has not really written in a flavour of Pascal, but in some very abstract Pascal; much an Algol: there is not a lot of Pascal idiosyncrazies left specifically to allow to convert the programs to whatever. ...

8

David Carlisle explains how to compile the sources for the modern versions of Tex that are the basis for Texlive (Pdftex, Xetex, and Luatex, among others). These derive from Karl Berry's Web2c fork of Knuth's source code, which is a mechanical way of translating code Web sources to C code that can be compiled just about anywhere. If you want to compile ...

15

You are linking there to plain.tex which is a file written in TeX not the source of tex-the-program (which is tex.web) These days if you want to compile from source it is probably best to start with a full download of the texlive build sources. The sources are at http://www.tug.org/texlive/svn/ and that page has hints about where to start if you want to ...

8

The short answer is 'no'. The longer version is that this primitive (almost certainly) cannot be implemented in macros: primitives rarely can be. In particular, \pdfstrcmp can do an expandable comparison of two sets of tokens on a character ('string') basis, without loosing any spaces. In the past, the LaTeX3 team did have some code which attempted to do the ...

6

AFAIK no. The only authority here is the publisher; please ask this question there, although I have not found an easy way to address that question on their website... :-( Edit: I personally doubt that DEK is satisfied with the typography of ePubs (which is essentially XHTML & CSS) and would demand PDF - and since the publisher(s) would then probably ...

4

Rather than digging into the internals, let's just parse the documented behavior. \ifdefempty: Expands to true if the control sequence is defined and is a parameterless macro whose replacement text is empty, and to false otherwise. This means that \ifdefempty{\cs} tests whether \cs is a macro (i.e. a non-primitive control sequence that is expandable) ...

7

Assuming \<cs> passes the first two tests of \ifdefempty (is defined and is parameterless), the next test - is the replacement text empty - is performed within \etb@ifdefempty. This test checks whether the \meaning of \<cs> is "blank": \def\etb@ifdefempty#1{% \expandafter\expandafter \expandafter\ifblank \expandafter\expandafter ...

14

With \def\myrelax{\relax} macro \myrelax is a parameterless macro with replacment text \relax. You get a command sequence with meaning \relax with \let: \let\myrelax\relax Also \def\myemptyempty{\myempty} defines a parameterless macro \myemptyempty that is not empty, whose replacement text is \myemptyempty. There is \edef that expands the replacement text ...

5

Knuth didn’t want to make a whole new programming language, he just wanted to have a typesetting language. Making TeX a Turing complete language was lobbied by Guy Steele [TEXTURING]. The word “Turing complete” gets thrown around a lot for some reason. Guy Steele is known for, among other things, as the co-author of the so-called Lambda papers [LAMBDA] ...

7

Every time I see this question I feel like there should be something more to say, so let me take a shot now. From my perspective, the intent of TeX's design vis à vis expansion is that it should provide a means for transforming simple input into complex typesetting directives. It is a programming language only insofar as it programs the virtual ...

1

Rather than showing each command separately you can get TeX to show you the current math list structure. \documentclass{article} \usepackage{amssymb} \begin{document} $a \sin b \upuparrows \times 2 \showoutput \showlists$ \end{document} Produces, on the terminal and log: ### math mode entered at line 5 \mathord .\fam1 a \mathop\nolimits .\mathord ...

4

It is surely impossible to have all of the following conditions: No clubs/widows TeX must not change the paragraph Number of lines must be fixed Since TeX breaks paragraphs before looking at pages, it has no chance to redo 2). With LuaTeX you could probably cook your own automatic solution, but this is pretty much the opposite of 'trivial'. In PDFTeX ...

9

Use \show\upuparrows instead. You will get this response: > \upuparrows=\mathchar"3414. Now you need to decode that. As explained in section 21.1 of TeX by Topic, that code is parsed as "xyzz where x is the math class, answering your question right there – while y is the font family number and zz is the position of the character in the font. To add a ...

3

Here's another option, producing the desired alignment (with the same warning as in David's answer: "This may have broken some other constructs in the package, but..."). Since the code uses \tikzmark, two (or three) runs are needed for the code to stabilize: \documentclass{article} \usepackage{xlop} \usepackage{tikz} \newcommand\tikzmark[1]{% ...

4

This may have broken some other constructs in the package but.... \documentclass{article} \usepackage[]{xlop} \makeatletter \def\op@divdisplayone{% \begingroup \op@count@z=\z@\relax \op@count@i=\OP@a@w \loop \ifnum\@nameuse{OP@a@\the\op@count@i}=0 \advance\op@count@i by-1 \advance\op@count@z by1 \repeat ...

13

The tex paragraph-building algorithm works by dynamic programming and is described in Knuth, Donald E.; Plass, Michael F. (1981), "Breaking paragraphs into lines", Software: Practice and Experience 11 (11): 1119–1184, doi:10.1002/spe.4380111102. The fact that it uses dynamic programming limits some of the types of penalties that can be implemented, but ...

17

There's no linear programming involved. TeX stores items in lists (vertical, horizontal or math lists). Math lists are converted to horizontal lists, so only the first two must be discussed, but they are alike when setting the glue is involved. Glue is stored as a glue item, represented with its natural width, stretch component and shrink component. When ...

9

In simple cases, you can use LaTeX's \@removeelement: \documentclass{article} \newcommand*{\citylist}{derby,leicester,nottingham} \makeatletter \@expandtwoargs\@removeelement{leicester}\citylist\citylist \makeatother \typeout{\citylist} \begin{document} \end{document} Result: derby,nottingham Simple means, the list is normalized without optional ...

7

The expl3 suite can manage comma separated lists in many ways. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\createlist}{mm} { \clist_new:c { g_wickerson_data_#1_clist } \clist_gset:cn { g_wickerson_data_#1_clist } { #2 } } \NewDocumentCommand{\addtolist}{mm} { \clist_gput_right:cn { g_wickerson_data_#1_clist } { #2 ...

Top 50 recent answers are included