{tex-core} is for questions that are independent of formats and macro packages. Such questions usually relate to low-level TeX programming or the behaviour of TeX at an underlying level. Note that even Plain TeX is a format in itself; for questions about it, use {plain-tex}.

learn more… | top users | synonyms (1)

23
votes
2answers
534 views

Backward definition of (La)TeX commands

Again and again I see, that TeXnicians define commands and do several things with them in the reverse order, I would do this as amateur. See this example: In his answer to scrpage2: Three ...
23
votes
1answer
1k views

What are the differences between TeX counts and LaTeX counters?

The title already states the whole question. It has been answered by Joseph Wright at http://www.texdev.net/2009/11/17/tex-counts-and-latex-counters/, but I have not seen the according answer here at ...
23
votes
1answer
315 views

What does list mean in relation to skip? (What is David on about?)

In two previous question When is it good practice to use \unskip and What is a token? the default meaning of token in LaTeX and the behaviour of \unskip were asked. However in the first question was ...
23
votes
1answer
870 views

Use of \relax after \ifnum … \fi construction

I'm reading Malcolm Clark's A Plain TeX Primer. On page 111 there's an exercise to define a macro that prints the current time. I've reproduced Clark's answer below: \newcount\minleft ...
22
votes
3answers
466 views

Making a zip macro

In functional languages, there often is a function called zip, which can be handy in many situations; for example in ruby, one can say: %w(a b c).zip(%w(d e f)) to get an array of arrays [["a", ...
22
votes
2answers
1k views

What’s behind \over?

Typically a TeX command have arguments coming after it. But the command \over, which is used to produce fractions, can access the token before it. How exactly is it implemented and can I define a ...
22
votes
3answers
459 views

If I redefine a command that has a starred variant, will that always disable the starred variant?

If I redefine a command that has a starred variant, will this always effectively disable the starred variant, as a side effect of redefining the unstarred variant? A related question: Do starred ...
22
votes
5answers
1k views

More Modern Reimplementations of TeX

There is no doubt that the original Pascal/WEB implementation of TeX is a masterpiece and I have learnt a lot reading through the source code (both weaved and tangled) but it definitely shows its age. ...
22
votes
4answers
589 views

Can one define an expandable command that removes control sequences from its argument?

I am trying to create an expandable command that accepts a single argument that may contain control sequences, and expands to that same argument with all control sequences and braces removed. That is: ...
22
votes
2answers
4k views

How do I split a string?

I need to split a string into one or more substrings. I know that I could use the xstring package, but I'd like to do it using only inbuilt TeX/LaTeX commands. So, if I say \def\MyTeXKnowledge{Not ...
22
votes
1answer
266 views

Is \def sensitive to spacing?

In the code below, it took me a long time to figure out that the space in the second line below beginning with \def generates an error. I'm new here. Where is the documentation of \def that would ...
21
votes
5answers
2k views

What on earth is iTeX?

Is that an hoax? Or is it a real wish from D. Knuth? (http://river-valley.zeeba.tv/media/conferences/tug-2010/Don-Knuth)
21
votes
3answers
1k views

Why does TeX remove braces around delimited arguments?

On pp. 203–204 of the TeXbook, Knuth describes how TeX absorbs macros' arguments: delimited go until the first appearance of the delimiter, and undelimited go until the next token, in both cases ...
21
votes
2answers
684 views

The role of %&latex at the beginning of a source latex file

Could someone please explain what is the role of %&latex which is put in a source LaTeX file before \begin{document} command?
21
votes
2answers
678 views

Which is better: a dimension or a macro?

When messing around with TikZ/PGF then I frequently find myself wanting to store a length for later use. By "length" here, I mean the word in its non-TeX meaning. As I'm doing stuff in TikZ/PGF then ...
21
votes
6answers
950 views

LaTeX Markup Options?

I was wondering what prevented the implementation of a MarkDown system in (La)TeX? I know that pandoc does a conversion of MarkDown with extra features to LaTeX. I also know that many are happy with ...
21
votes
2answers
316 views

Lifespan lines in TeX

I'm writing a document (written in plainTeX) about the lives of important mathematicians and physicists in human history. Now I have a problem I'd like to tackle. I need to be able to visualize their ...
21
votes
2answers
4k views

What's the difference between \tolerance and \badness ?

I'm having some difficulty understanding this sentence on page 29, Chapter 6 of Knuth's TeXbook: Run TeX again, and begin this time by saying \hsize=2in \tolerance=1600 \input story ...
21
votes
1answer
674 views

Why do the definitions of \quad, etc. have \relax in them?

Plain Tex defines \quad so: \def\quad{\hskip1em\relax} Why is the \relax there? It's usually used as a token that can't be expanded, serving as a "do nothing" operation after macro expansion is ...
21
votes
1answer
593 views

Why can words with hyphen char not be hyphenated?

Assume I have a word like Baden-Württemberg. TeX can't hyphenate any of these two word parts. Why? why isn't it something like this: where the small ticks indicate possible hyphenation points. A ...
21
votes
1answer
134 views

Is implicit `\relax` in conditionals explained anywhere in the TeXbook?

I have been relying for years on TeX's behavior where, say \if1\fi expands to nothing and \if1\else\fi does the same. In the second case TeX inserts an 'implicit' \relax when it tries to expand \else. ...
20
votes
4answers
455 views

How does TeX's mechanism for sorting out quotation marks work?

When I enter ``hello'' in TeX, it very nicely reformats it to some nicer version of "hello". The mechanism for this seems to be buried deep down in the depths of TeX (and I can't find it in my usual ...
20
votes
5answers
1k views

Where do I find \futurelet's nasty behaviour documented?

Until recently, I thought that execution of \futurelet\testtoken<token1><token2>... has the following effect: The control sequence \testtoken is \let to <token2> and ...
20
votes
2answers
1k views

TeX's algorithms for “breaking paragraph into lines” and “setting the glue”

I want to learn more about the implementation of TeX's text-justification algorithm (setting the glue). After scanning through ch.12 of Knuth's TeXbook, I'm guessing that setting the glue must ...
20
votes
2answers
346 views

Get the lion to run in loops. Tersely

Various constructions can cause TeX (aka the lion) to go into an infinite loop. The simplest example is \def~{~}~, which defines ~ to expand to itself, then expands it. Now, if we exclude macro ...
20
votes
3answers
605 views

Whatsits: when are they used in practice?

This question came up in discussions surrounding the question How to replace a large block of text by an empty block of the same size?, which basically asks for a vmode analog of \phantom. My question ...
20
votes
2answers
8k views

\nothing, \varnothing and \emptyset

This is probably a question about TeX's history. Why there is no command \nothing? If there's no \nothing, why \varnothing is called \varnothing instead of \nothing? If I try to compile a document ...
20
votes
1answer
176 views

How to delay a command execution until the next hmode?

I want to write an environment which adds a marginnote at the begin. The problem is that I can't control the content of the enviroment and so the placement of the marginnote varies a lot. How could I ...
19
votes
5answers
1k views

How does one append material to a token list?

Several times, the floatrow package uses \newtoks which (according to this website) means that a token register is allocated. An example code snippet is ...
19
votes
4answers
511 views

Scaling a glue in TeX

is there a possibility to scale a glue in TeX? Consider the following example: \newskip\foo \newskip\bar \foo=10pt plus 2pt minus 3pt \bar=2.5\foo\relax \showthe\foo \showthe\bar \bye When ...
19
votes
2answers
416 views

\expandafter and \aftergroup: where do the 2n+1 and n^2-1 rules come from?

Both TeX primitives \expandafter and \aftergroup have "rules of thumb" stating that \expandafter should be used 2n+1 times to look n tokens ahead (is this correct?). A similar "rule of thumb" holds ...
19
votes
4answers
448 views

Extract all emphasized words from latex document

I need to produce a list of all words that are emphasised in my LaTeX document (=which are enclosed by \emph{...}). How can I use awk to process the .tex file and extract all patterns starting with ...
19
votes
7answers
2k views

What is the canonical way to write a for-loop macro?

At a basic level TeX does not provide a for-loop construct, but allows tail-end recursion, however Knuth defined \loop in the plain macros. Coders have been coming with variations of their own ever ...
19
votes
3answers
328 views

Where can I find a documentation for low-level tex conditionals like \if?

I want to understand low-level stuff like \if better. I'm not looking for some random examples off Google showing me some statements but a specification of some sort - something mean and unforgiving. ...
19
votes
3answers
4k views

What is the difference between \ifx\somecommand\undefined and \ifdefined\somecommand\else?

What is the difference between \ifx\cyrdash\undefined and \ifdefined\cyrdash\else? \cyrdash is any macro.
19
votes
2answers
264 views

global confusion

Simply put, when should I care if something is global or not? What does this really mean? If my package, for example, provides \newcommand*{\setfooter}[1]{\def\mypackage@footer{#1}} And I later ...
19
votes
3answers
1k views

Obfuscating TeX

Given TeX's system of catcodes, I imagine that one can obfuscate TeX to a remarkable degree. With a view to learning more about the internals of TeX, I ask: How might I go about adding a block of ...
19
votes
2answers
455 views

Outright impossible TeX byte sequence

Out of a hacker's interest, I am wondering if there is any byte sequence that can never occur in any valid TeX document before \end is processed. I thought of things like {\catcode`}=9\catcode`\=9 ...
19
votes
1answer
967 views

Why are the latex, pdflatex and pdftex binaries identical?

I apologize if this question is somewhat off-topic but I think that this is the best place to find an answer. This is sort of an oddity that's confused me for years. When I run latex -v I get: ...
19
votes
2answers
397 views

What is \box255?

I'm just reading the everyshi manual, and it says: This package provides the hooks \EveryShipout and \AtNextShipout whose arguments are executed after the output routine has constructed ...
19
votes
1answer
1k views

Knuth's line breaking algorithm

I'm trying to understand the basics of Knuth's line breaking algorithm. At the beginning of Chapter 12: Glue of his TeXbook, there is a figure like the one below. My question is: where did those ...
19
votes
1answer
376 views

How do I get into XeTeX development?

The support for OpenType fonts has been a great advancement in terms of usability. Unfortunately the microtype package does not offer font expansion for OpenType fonts in XeTeX. I dug a little ...
19
votes
1answer
501 views

When can one use implicit braces instead of explicit braces?

For context, an implicit character is a control sequence that has been \let to a character. For example, both plain TeX and LaTeX use \let\bgroup{ \let\egroup} making \bgroup and \egroup into implicit ...
18
votes
4answers
3k views

How to compile the source code of TeX

I am more and more interested in the system TeX (and LaTeX) and I want to study it more deeply. I am not telling that I want to learn how to use it, but I want to understand its mechanism now. The ...
18
votes
1answer
902 views

How does TeX actually work?

Lots of useful information for human beings, especially in academia. But, what is actually underlying the TeX engine? How does it really work? Does it parse everything and just put the stuff together? ...
18
votes
4answers
2k views

How to make a real backslash (escape) character?

I just want a good way to make a backslash character (or whatever character(s) any given format uses as escape characters), suitable to \write to a file or pass to a pdfTeX primitive. Let me ...
18
votes
3answers
805 views

What is a “Control Sequence”?

When you get an error in LaTeX, the message "Undefined control sequence" is printed. Why is it called "control sequence" and not "command", for example? How does the sequence work? Is this a TeX or ...
18
votes
2answers
1k views

Difference between \let\foo\relax and \def\foo{} for disabling

When I want some macro to (temporarily) do nothing, I normally write \let\foo\relax But somebody asked me why I don't just do \def\foo{} and I realized I couldn't answer his question. So, I ...
18
votes
1answer
802 views

Is it still worthwhile to let TeX try line-breaking without hyphenation?

Here's TeX's line-breaking approach (as I understand it) in a nutshell: If \pretolerance is positive, try to break a paragraph into lines without inserting discretionary hyphens and without ...
18
votes
1answer
293 views

Plain TeX online documentation/references?

I am a non-beginner plain TeX user, mostly typesetting cheat sheets for computer science. I own The TeXbook and have seen some TeX manuals for the compilers, such as pdfTeX manuals and so forth. My ...