{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)

21
votes
7answers
380 views

Fully robust way to access the first item in a token list (expandably)

Given a token list such as \a\b\c or {ab}c, I define the first item to be what \@gobble would get as its argument (recall the definition \long\def\@gobble#1{}). It is not hard to devise a macro which ...
21
votes
3answers
328 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 ...
21
votes
2answers
2k views

What are the exact semantics of \detokenize?

How does \detokenize work? The e-TeX Short Reference Manual states: When followed by a <general text>, expands to yield a sequence of character tokens of \catcode 10 (space) or 12 ...
21
votes
2answers
646 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
799 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
4answers
497 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: ...
21
votes
2answers
306 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
1answer
667 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 ...
20
votes
4answers
426 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
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 ...
20
votes
5answers
976 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
596 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?
20
votes
1answer
479 views

How does a TeX engine read and render the input stream?

I am new to TeX programming and I have not finished reading the TeXBook yet. I need at a glance tutorial about how a TeX engine reads, processes, and produces its output. My mental model as a newbie ...
20
votes
2answers
893 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
3answers
555 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
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 ...
20
votes
1answer
122 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. ...
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
410 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
3answers
3k 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
245 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
444 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
374 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 ...
19
votes
2answers
6k 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 ...
19
votes
1answer
476 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
2answers
307 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 ...
18
votes
2answers
737 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
2answers
332 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 ...
18
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 ...
18
votes
1answer
257 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 ...
18
votes
1answer
305 views

Drawbacks of redefining math accents with extra leading {}?

As I discovered through the non-bug latex/4253, TeX has a (mis)feature whereby it ignores braces around a \mathaccent construction: ${a_b}_c$ works, but ${\tilde a_b}_c$ fails with a "Double ...
17
votes
4answers
700 views

Which commands consisting of a non-letter eat spaces afterwards?

Command names consist of a sequence of letters (until and excluding the first non-letter) or of a single non-letter. Command names ending in a letter (including of course those consisting of a single ...
17
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.tv/media/conferences/tug-2010/Don-Knuth)
17
votes
3answers
2k 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 ...
17
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 ...
17
votes
1answer
691 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? ...
17
votes
3answers
298 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. ...
17
votes
2answers
366 views

Why does this simple \ifx test fail?

This should be easy, but I don't understand why the test below fails... I expected Hurrah! to be printed when the \currentchar count reaches 90 (i.e. the character code of Z). There must be some ...
17
votes
5answers
1k views

Are there purely expandable variants of \MakeUppercase?

\MakeUppercase and \uppercase use TeX's uccode, and they are not purely expandable. Say, \edef\temp{\MakeUppercase{abc}} will fail. Sometimes purely expandable macros are very useful. They are ...
17
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 ...
17
votes
1answer
681 views

How does TeX handle \else and \fi in conditionals?

I have seen packages using \def\afterelse#1\else#2\fi{\fi#1} which TeX seems happy to accept. But on taking the first branch, isn't TeX expecting \else instead of \fi? That is, isn't the following ...
17
votes
1answer
135 views

What primitives can expandably tell us about the current horizontal list?

I've been writing some code that expands macros and catches characters and non-expandable primitives as they reach TeX's stomach, and I encountered an issue: since I gather letters one by one, with ...
16
votes
4answers
401 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 ...
16
votes
2answers
2k views

When is it good practice to use \unskip

One sees in source2e the command \unskip used in various places. My understanding in general terms is that the macro is the equivalent of \ignorespacesbehind. Where would it be recommended to use ...
16
votes
2answers
581 views

How does one publish/promote a new package?

I just took all the wonderful information supplied here, and wrote a small package that makes it possible to use Unicode characters for section, subsection, subsubsection, paragraph, subparagraph and ...
16
votes
2answers
292 views

Use of \everyeof and \endlinechar with \scantokens

The e-TeX \scantokens primitive allows retokenization of input. However, it is almost always used in a group where \everyeof and \endlinechar are set (see for example Can I convert a string to catcode ...
16
votes
3answers
897 views

Does `\noexpand` have to be a primitive?

Background: I'm trying to deepen my understanding of TeX and how the intricacies work (spurred a little by this place, I should say, and hoping one day to not be a "Cargo Cult Programmer" - see When ...
16
votes
1answer
884 views

What does \marks do?

Recently I had cause to define a macro called \marks. If I try something like \newcommand{\marks}{fred} I get the error ! LaTeX Error: Command \marks already defined. In LaTeX, if I do ...
16
votes
1answer
872 views

How do \lastskip and \ifdim work?

I thought I knew the answer to this question, but I can't understand the following plain TeX code: \noindent\hskip1pt\ifdim\lastskip=0pt lastskip was 0pt\fi\par \noindent\hskip1pt\showthe\lastskip ...