140

How about this? \documentclass{article} \usepackage{amssymb} \begin{document} \begin{tabular}{ll} Plain-\TeX{}: & ${\rm I\!R}$\\ amssymb: & $\mathbb{R}$ \end{tabular} \end{document}


99

TeX is useful when you want to fully understand what's going on, or want to have full control. In principle this is possible with LaTeX too, but there's a lot more to understand. (That is, LaTeX is easy but not simple, while plain TeX is simple but not easy. Related talk on software design.) TeX is a tool for typesetting; LaTeX is a document preparation ...


59

\sbox is a short form of \savebox in the same way that \mbox is a short form of \makebox for the common case where you do not need to specify any lengths and want the natural size of the box. \setbox is the underlying TeX primitive so it does not read its arguments as a normal macro (like the comparison between \hbox and \mbox) and it is not safe to use with ...


53

The reason is in the definition: \outer\def\bye{\par\vfill\supereject\end} So \bye doesn't just issue \end (that would by itself issue \par, but not \vfill): it also performs \supereject, which is \def\supereject{\par\penalty-\@MM} Why a -20000 penalty? The reason is in the output routine: \def\plainoutput{\shipout\vbox{\makeheadline\pagebody\...


39

Adding \def\patterns#1{} \catcode`\{=12 \let\newtoks\relax \let\dump\relax \let\+\relax \let\newinsert\relax \input latex.ltx To a LaTeX file makes it a plain TeX file. This is a LaTeX answer I gave to a question earlier today which runs without error in pdftex as modified: \def\patterns#1{} \catcode`\{=12 \let\newtoks\relax \let\dump\relax \let\+\relax \...


38

The "smallest" possible TeX is what Knuth called "virgin" TeX (TeXbook, p.342): it knows just primitive commands, no macros. Plain TeX is the set of macros (developed by Knuth) which makes TeX usable in everyday life of a typist. And yes, these days we're using many different sets of macros ... one popular set is of course LaTeX. Plain TeX is, well ... the ...


32

The main difference is that using \afterassignment you can preserve the assignment syntax. So in your counter example any number of tokens following \dosomething would be expanded until a sequence of non expandable tokens making a <number> are scanned. The second version forces a macro-argument syntax where the number has to be given as a single token ...


31

Here's a whirlwind of some of the things you can do with XeTeX (and to even larger extent, LuaTeX). Plain-kru putting a stop to this discrimination nonsense. \uselanguage{french} \frenchspacing \input eplain % http://tug.org/eplain/ \font\bodyfont="Liberation Serif:mapping=tex-text" at 12bp % ^ XeTeX-specific font-loading, see http://ctan.org/pkg/xetexref \...


30

The question has no answer, actually it meets the standard "opinion based" close reason. but I'll attempt an answer anyway. TeX is a macro expansion language, and LaTeX is defined as a set of macros, so everything that you write in LaTeX expands eventually to some sequence of TeX primitives. Conversely, TeX allows you to define macros, so starting from ...


27

\def\startcenter{% \par \begingroup \leftskip=0pt plus 1fil \rightskip=\leftskip \parindent=0pt \parfillskip=0pt } \def\stopcenter{% \par \endgroup } \long\def\centerpars#1{\startcenter#1\stopcenter} You can now choose between \startcenter Some text to be centered \stopcenter and \centerpars{Some text to be centered} An empty line in the ...


27

I don't know this primer, but I am a little leery of any book that claims to be instructional but cheerfully advises you to do something "just in case". There is always a reason; in this case, the reason is one of the characteristic quirks of TeX. The problem is not so much the \ifnum as the \advance. The amount by which you are to advance is scanned for ...


27

\def with \expandafter help: \expandafter\def\expandafter\MySaved\expandafter{\MySaved \MyText} If you are using LaTeX (\textbf, \textit, ...), then \g@addto@macro can be used: \makeatletter \g@addto@macro\MySaved{\MyText} \makeatother Or if you need complete expansion: \edef\MySaved{\MySaved \MyText} But that might break fragile stuff, thus LaTeX ...


26

The ASCII code of \ is 92, and this is also TeX's internal code for the backslash. Now have a look at Appendix F of the TeXbook (F like Font Tables). There you see that the typewriter font cmtt10 indeed has a \ sitting in position 92 (which is ´134 in octal notation), whereas the standard text font cmr10 has a quotation mark “ in that position. The ...


26

plain tex (uniquely) is usually used with the classic Tex engine (or at least with pdf and e-tex extensions disabled) so there is no infix arithmetic \newcount\zzz \zzz=5 \multiply\zzz by 3 \advance\zzz by 2 sets \zzz to 17. If you use the plain format with e-tex you can use e-tex infix arithmentic \newcount\zzz \zzz=\numexpr 5*5 + 2\relax


24

The end-of-line character is not available to be used in the main input stream, under the standard setting which is \endlinechar=`\^^M \catcode`\^^M=5 (see The ^^ notation in various engines for information about the ^^ notation). When TeX sees a character with category code 5, it immediately converts it either to a space or to a \par token if another ...


23

Plain TeX does not provide the 'pre-built' structural concepts which LaTeX provides, such as TOC, sections and so on. Instead, it provides the basic typesetting mechanisms from which you can build these up. As mentioned in the comments, Knuth's The TeXbook is not only the definitive reference for TeX but also a guide to how to create a book using plain TeX, ...


23

The answer why PGF 3.1 does not support Knuth TeX is two-fold. It is the current year. By now e-TeX is over 20 years old and has simplified TeX development tremendously. I consider it a bug on your side that you are not using e-TeX. Unfortunately TeX Live ships a tex binary which does not enable e-TeX extensions. You have to use etex instead. ...


22

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 ...


22

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 ...


22

plain tex and latex are both written in tex but have no tex code in common, so while some commands have the same name and some of the ones that have the same name have the same definition, it is a bad idea to use latex as a tool to learn plain. The TeXBook describes two sets of commands (and doesn't always go to great lengths to distinguish them, apart from ...


22

Look ahead for the [: \def\stile{\futurelet\next\dostile} \def\dostile{% \mathrel{|\mkern-4mu{-}} \ifx[\next %] \expandafter\dostileopt \fi } \def\dostileopt[#1]{_{\rm #1}} $\stile \alpha$ $\stile[K] \alpha$ \bye


21

What \show doesn't show is that the p and the t are expected to have catcode 12 (other), since they were assigned that catcode when \\ was defined. Your definition of \mymacro is therefore not the same, since here the letters are indeed letters (catcode 11). Why did Knuth define a delimited macro with such strange catcodes? Because this way, \\ can be used ...


21

Without reinventing the wheel, we can use etoolbox: \appto{\MySaved}{\textit{More text}} with \gappto if the change should be global. If you want to add to \MySaved the (first level) expansion of \MyText, there's \eappto{\MySaved}{\expandonce{\MyText}} and \xappto will do the same globally. Let's see: \documentclass{article} \usepackage{etoolbox} \def\...


20

Plain TeX is really an example format rather than something for making documents in so you almost always have to load something to get a document usable setup (manmac, or eplain or amstex or your own macros) but anyway keeping to plain as far as possible. \documentclass{article} % It's not really important I can work without a class. Just do nothing, plain ...


20

If you want to use Knuth TeX you'll have a hard time. With pdftex it's easier, because there are some useful features coming from e-TeX extensions. Here's a seemingly working setup (I add only a reduced version of the first file, for the limitation in characters here. utfplainmac.tex % -*- coding: utf-8 -*- % We set a safe catcode for ^ and ^^^; XeTeX ...


19

Hendrik's answer is great. Nevertheless, please allow me to elaborate on \string and \escapechar a little more: Like you said the \string primitive converts a control sequence into a list of character tokens1. It also works on other tokens and turns them into their string representation. Two things are notable here: All characters with the exception of ...


19

A \catcode`@=11 command is executed as soon as TeX encounters it when consuming tokens (as opposed to doing expansion). Basically TeX works on a list of tokens trying to consume it. When it finds an expandable token it performs the expansion and continues to do so until an unexpandable token is found. In this case it sends it (with its arguments, which ...


19

The manmac format used for processing the TeXbook defines ^ in a very special way. Under the standard setup, ^ alone is the marker for superscripts and also has a very peculiar behavior when followed by itself, see What is the role of an unescaped circumflex or hat character " ^ "? However, manmac.tex makes ^ into an active character and Knuth ...


19

You can use the ε-TeX primitive \numexpr for expandable integer expressions. The only restriction is that it won't work in engines without ε-TeX extensions (mostly Knuth TeX nowadays), in which case you need to go with siracusa's solution. These macros being expandable, allows you to use them anywhere TeX expects a number, like in \ifnum, \...


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