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

12
votes
1answer
1k views

Why does \hss fail?

Please why does the following fail? % \hss -> \hskip 0pt plus 1fil minus 1fil \setbox0=\hbox{a}% \setbox0\hbox to 10mm{\hss\unhbox0\hss} \unhbox0 And what makes LaTeX's ...
12
votes
2answers
424 views

New lines and TeX: difference between ^^J and ^^M

What is a new line for TeX in the following contexts: When reading from a file. When writing to a file. After having read a % character. In a \scantokens. I am asking in particular because the ...
12
votes
2answers
138 views

Document equivalence

What is the best way to determine, for two arbitrary input files, if they will result in the same compiled document (disregarding timestamp information and external files)? Context I'm attempting to ...
12
votes
1answer
708 views

How to prevent extra spaces between two specific words when justification occurs?

My document contains many short, justified lines, so the lines often appear with many spaces between words, e.g.: These words have a space so that they can fit nicely into the available ...
12
votes
1answer
267 views

\show with fewer lines?

I am writing some macros for general debugging purposes (See Yiannis' question). I am basically expanding a given input step by step, and printing the result to the terminal and log. In order for this ...
12
votes
1answer
85 views

Tight connection of \vbox es

I don't understand why TeX put a thin whitespace between my two vertical boxes: \documentclass{article} \begin{document} \vbox to 1cm {\rule{1cm}{1cm}} \vbox to 1cm {\rule{1cm}{1cm}} ...
12
votes
1answer
169 views

Hide ^^^^-notation from pdftex

The following example gives when compiled with pdflatex the error ! Text line contains an invalid character. \documentclass{article} \usepackage{ifluatex} \ifluatex \usepackage{fontspec} \fi ...
12
votes
1answer
279 views

Test if a number is in a comma separated range/list of numbers

Martin Scharrer posted a very elegant answer for the question "Creating a zebra effect using listings". I want to extend that code to highlight only lines given in a comma separated list. The ...
12
votes
1answer
278 views

How can latex and pdflatex be both symbolic links to same executable (pdftex) and not behave the same?

When I run $ latex my_doc.tex and $ pdflatex my_doc.tex it works, and when I run $ pdftex my_doc.tex it doesn't work. The thing is I noticed that both LaTeX and pdflatex commands are ...
12
votes
1answer
784 views

Simple un-obfuscation of some LaTeX internals

Here's an example of some code from LaTeX's \DeclareFontFamily: \def\reserved@a{#3} \global \expandafter\let\csname #1+#2\expandafter\endcsname \ifx \reserved@a\@empty \@empty ...
12
votes
1answer
315 views

Is Knuth's *The TeXBook* complete?

Suppose I want to learn TeX. Then, is The TeXBook a complete source? Does it cover all relevant aspect of TeX? Or is there something worth learning about TeX which is not present there? Does also ...
11
votes
3answers
501 views

How could the macro xii.tex be simplified into a better readable form

I was reading some TeX guides from where I have found this source: \let~\catcode~`76~`A13~`F1~`j00~`P2jdefA71F~`7113jdefPALLF PA''FwPA;;FPAZZFLaLPA//71F71iPAHHFLPAzzFenPASSFthP;A$$FevP ...
11
votes
2answers
542 views

() or {} after a command

I was wondering why for some commands it is "(...)" that follows, while for other commands it is "{...}". For example, "\exp(x)" and "\bar{x}". Are both () and {} for specifying the arguments for the ...
11
votes
3answers
478 views

Does the \relax side-effect of \csname…\endcsname still have a use?

I find it annoying that using \csname...\endcsname will define ... to be \relax if ... is undefined, and there is no improved primitive that does not have this side-effect, though there are partial ...
11
votes
4answers
202 views

Partially expanding a command

My \john command is defined like so: \def\john{\DontExpandMe} I would now like to repeatedly change its definition, to keep adding some extra stuff on the front. \foreach\i in {ape,bat,cow,dog} { ...
11
votes
3answers
366 views

Understanding etoolbox \ifdefempty and \ifdefvoid

I am trying to understand the etoolbox \ifdefempty and \ifdefvoid macros. The documentation says that \ifdefempty Expands to true if the control sequence is defined and is a parameterless macro ...
11
votes
2answers
627 views

How to get the catcode of a token?

For debugging a complicated macro I would like to print out the catcode of a token. Optimally I would like to have a macro \getcatcode such that, for example, \getcatcode{a} would expand to 10. How ...
11
votes
3answers
351 views

Parser for decimal numbers in (plain) TeX

I need help writing a parser for decimal numbers using only TeX and plain TeX. The set of accepted inputs is given by the regular expression: (+-)?(0-9)*(.,)?(0-9)+ The parser need not do anything ...
11
votes
2answers
142 views

Does a space belong after pt?

Does a space always belong after pt, e.g. as used in \hskip1pt? If a space is used, are there situations where a space will appear where it is not intended? If no space is used, will pt be ...
11
votes
2answers
205 views

Creating new primitives

Consider the following TeX: \tt ~~~[def]: \meaning\def \par ~~~[let]: \meaning\let \par [define]: \meaning\define \par ~[macro]: \meaning\macro \def\macro#1{some ...
11
votes
4answers
337 views

How can I compare two (not necessarily integer) variables?

After experimenting and researching for hours, I still cannot figure out how to perform a simple equality test between two numbers. More specifically, here, the two numbers in question are the ...
11
votes
2answers
322 views

How is \unexpanded defined?

I was wondering how \etoolbox's \expandonce does what it does. So I looked up how it was defined and found \unexpanded\expandafter{#1} But no matter where I look, I cannot find a definition for ...
11
votes
3answers
298 views

Expandable 'character scanning' command that preserves spaces

David Carlisle recently offered a clean and rather elegant TeX solution to a question about expandable 'character scanning' commands. Unfortunately, David's solution does not preserve spaces in the ...
11
votes
5answers
1k views

Teach me how to use \loop…\repeat constructs, etc

The following code snippet is a part of the solution given here: \def\IncludeOutput#1{ \parskip=2mm \def\examplename{#1} \pdfximage{\Directory/\examplename.pdf}% ...
11
votes
3answers
190 views

Command delimited by return or blank line

I have this document \documentclass{scrartcl} \long\def\quotenextparagraph#1 {\begin{quote}#1\end{quote}} \begin{document} Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ...
11
votes
4answers
115 views

A question about macro matching

Consider the following macro definition, and subsequent invocation: \def\foo #1 #2 \bar{stuff with #1 and #2 goes here} \foo arg1 arg2 \bar The \bar simply acts as the terminator for \foo. This all ...
11
votes
1answer
170 views

(Re)definition of commands that use delimiters other than braces (e.g. \underbrace)

How do you go about redefining a command such as \underbrace, which uses an "uncommon" delimiter, i.e. _, between its two arguments, so that the redefined command be usable in exactly the same way as ...
11
votes
3answers
510 views

How to display only certain lines of a paragraph?

From reading Knuth's TeX Book (Chapter 14 How TeX Breaks Paragraphs into Lines), I understand that entire paragraphs are read in and then "massaged" by the "line-breaking algorithm" in an optimal way ...
11
votes
3answers
270 views

List (at run time) the macros that are currently defined

TeX of course knows at any time what control words and symbols are defined. Is it possible to access this information, for example at the end of a run? Edit: the answer for pdfTeX is no, since the ...
11
votes
1answer
565 views

Using \toks registers

I was reading this tutorial for TeX programming: http://pgfplots.sourceforge.net/TeX-programming-notes.pdf recommended in the 2-nd answer here: Where do I start LaTeX programming? It says: ...
11
votes
1answer
609 views

Consume/absorb a token

How does consume/absorb/remove a token from then token stream in TeX? I'm using @ifnextchar and would like to remove the character it matches.
11
votes
1answer
145 views

Begin/end a logical block?

Can I create a logical block (like HTML div element), so I can apply features like \centering locally, but not affect the outside environment?
11
votes
2answers
762 views

Tricks to make macros expandable

Expandable macros are useful (I find working in the lion's mouth super cool). But they are difficult to write. Can more experienced users give hints that help achieve expandability? For example, we ...
11
votes
1answer
3k views

Origin and formation to the ERROR ‘Dimension too large’

When I tried to compile: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[very thin, red] (0,0) circle (2); \foreach \i in {0, 1, 2, ..., 46} \draw[very thin, ...
11
votes
1answer
660 views

How to do \scantokens inside \edef without triggering “Runaway definition”

I'm trying to find a way to use the e-TeX \scantokens command inside [the equivalent of] an \edef (well, actually an \xdef, but presumably this does not make any real difference since that's just the ...
11
votes
1answer
525 views

What is the function of \noalign?

The use of \noalign is quite common. For example here \noalign is used with \vskip{}to control the height of a table cell. How does \noalign work in general, and how does it work with \vskip? ...
11
votes
1answer
158 views

XeTeXpicfile in vertical mode

Given a minimal like \line{% \vtop{\hsize=.6\hsize Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse tempor lectus sit amet laoreet convallis. Quisque at est lacinia, porttitor ...
11
votes
1answer
84 views

How to define a command using \lowercase in \csname

I was being lazy and had a lot of commands of the form \def\foo{...Foo...} So I was thinking about taking an approach like ...
11
votes
2answers
439 views

Difference between unrestricted and internal vertical mode

At any point in the processing of a document, TeX can be in one of seven modes: no mode (only in \write and similar commands, I think), math mode ($...$), display math mode ($$...$$), restricted ...
11
votes
1answer
88 views

\toks register expansion issue - or is it?

I am trying to assemble a table that occurs multiple times throughout a document. It always consists of some fixed columns, followed by a set of columns that appear in one table but are not needed in ...
11
votes
2answers
135 views

increase \hyphenation{word1 word-2…} capacity

We use LaTeX to typeset a large collection of books with many proper names. We use the \hyphenation{word1 word-2...} command to specify words that should not be hyphenated and to suggest hyphenation ...
11
votes
1answer
285 views

TeX capacity exceeded, sorry [semantic nest size=500]

Reading through tex.web, I note that there is a difference between grouping levels and semantic nesting (i.e., the nesting of math, horizontal, and vertical modes). I can think of commands which ...
11
votes
2answers
188 views

What combinations of mode and \currentgrouptype exist?

I am trying to predict in any given situation what TeX does if a closing brace reaches its stomach (apart from reverting local assignments). For instance, \vbox{\tracingall H} shows that if it is in ...
11
votes
2answers
142 views

Is there any reason to define a zero-argument macro using a starred defining command?

Is there any reason to define a 0-argument (read: zero-argument) macro with a starred command (\newcommand* instead of \newcommand or \DeclareRobustCommand* instead of \DeclareRobustCommand)? After ...
11
votes
1answer
145 views

How many different concepts of “token equivalence” are there in TeX?

I was living in the delusion that the "token equality" tested by \ifx was the only thing you need to remember about this subject, but this week I learned otherwise (thanks to David Carlisle). Now ...
11
votes
1answer
93 views

Measure total glue in a box

Someone gives me a box, and my goal is to know as much as possible about the amount of glue inside that box. I can assume that the box is not huge, but it may contain arbitrary stuff (so I cannot ...
10
votes
3answers
395 views

Why is tex designed to render spaces around brackets?

When I wrote following lines: \section{Introduction}{ Content in introduction ... } Unwanted space comes before Content as warned. I understand it's due to some technical decision in tex. But I ...
10
votes
4answers
483 views

Extract first, last and rest of tokens

This question is related to Extract first & last characters of macro argument?. It seems that if, besides getting first and last tokens, one wants to accumulate the rest of the tokens, the ...
10
votes
3answers
846 views

Check for empty macro argument

There is a description on how to check whether the argument of a macro is empty in What does \ifx\\#1\\ stand for? Unfortunately, I can't get any of the examples there to work. Among others, I have ...
10
votes
2answers
256 views

All (La)TeX warnings and errors

For testing purposes, I am looking for a comprehensive list of all errors and warnings that TeX, and LaTeX can output. I don't mean errors and warnings produced by all packages, as this would give an ...