Questions tagged [tex-core]

{tex-core} is for questions for syntax, semantics and expected behavior of TeX primitive control sequences, regardless of extensions (eTeX, etc.) formats (Plain or LaTeX) and macro packages (tikz). 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}.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
24 views

The information of corresponding author placed below the title, instead of in the footnote

Hello. Editor wanted me "The information of corresponding author should be placed below the title, instead of in the footnote." Also, I don't know why the sentence preprint submitted to ...
103 votes
5 answers
13k views

Is there a BNF grammar of the TeX language?

I'm looking for a BNF grammar of the TeX language, does it exist? EDIT For those of us who are not computer scientists, a BNF grammar is one kind of formal description of a CFG: Backus Naur Form. ...
2 votes
2 answers
170 views

How to make a recursive macro

The following simple example is for typeseting (a)(b)(c)(d) by recursion. An error massage ERROR: LaTeX Error: \begin{document} ended by \end{)}. is received when running the code. What's wrong with ...
3 votes
3 answers
94 views

Does \ifx compare conditionals differently than other tokens?

I'm getting an unexpected result with parsing loop that uses \ifx. My understanding is that, for control-sequences, \ifx looks for "top level" equivalence and the same modifiers like \long. ...
0 votes
1 answer
40 views

Tex, Lyx misplaced \noalign with \input

I have a file that, after some struggles, is now working in lyx. However, if I export to tex and run from texstudio I get the original misplace \noalign error I had previously got in Lyx. Here's the ...
4 votes
3 answers
359 views

Accessing TeX's internal tokens

Section 23.7 of source3.pdf lists all possible tokens, such as the usual characters and control sequences, but also some of TeX's internal ones. Expanding \the\font results in a token that looks ...
27 votes
7 answers
2k views

Most efficient way to reverse a token list (tail recursion)

Goal: reverse a list of characters, going from \def\mylist{abcdefgh} to \def\mylist{hgfedcba}. This is easy using a marker which does not appear in the list, such as \relax: \def\mylist{abcdefgh} \...
0 votes
0 answers
25 views

Two matlab2tikz figures side by side

I want to have two figures generated with matlab2tikz side by side. I tried \documentclass[12pt,a4paper]{report} \usepackage{parskip} \usepackage{blindtext} \usepackage[onehalfspacing]{setspace} \...
0 votes
0 answers
26 views

citation style as (authors, year) instead of [number]

The editor of a journal asked me to citation style as (authors, year) instead of [number]. Groups of references should be listed first alphabetically, then chronologically. Please look at my .texcode ...
0 votes
0 answers
36 views

TeX: position word underneath another word in the paragraph [closed]

I’m trying to format underline translation (word under word) using TeX. How to do that?
1 vote
1 answer
21 views

"Argument has an extra }" error when using reference command with optional argument in theorem note

I'm trying to add a reference (with optional argument) in the theorem note. Below is a MWE. \documentclass{article} \usepackage[french]{babel} \usepackage{amsthm,create-theorem} \CreateTheorem{...
0 votes
0 answers
30 views

Newest version of luatexja interferes with vertical alignment of text

Today when I was compiling a document, I found that the header was mis-aligned. After a bit debugging, it seems to be the package luatexja (version 20220807) that is causing the problem. Below is a ...
1 vote
0 answers
24 views

Compilation never ends with modified \pmod after recent update

In this answer, @egreg provided a modified \pmod with a starred variant. However, after some recent update to the TeX distribution this modification no longer works (the last time I used this command ...
3 votes
3 answers
178 views

Why last character in TeX's input buffer must not be blank?

In §31 of tex.web it is said: Trailing blanks are removed from the line; thus, either |last==first| (in which case the line was entirely blank) or |buffer[last-1]!=' '|. Input should be the same ...
10 votes
2 answers
1k views

What is the difference between \write16 and \message?

\write16 sends to terminal, \message also does this. Why there are two commands for this and in which cases each one must be used?
0 votes
1 answer
43 views

Recovering discarded items in the output routine

A problem I had with TeX years ago was that discardable items (glue items, kerns, and penalties) are not recoverable in the output routine. This would be quite useful for complex multi-column pages ...
0 votes
1 answer
36 views

\skip_vertical:n and \vspace between two tcolorbox environments

What is the difference between \skip_vertical:n and \vspace? In the following example, the \skip_vertical:n has no effect, but if one changes it to \vspace then it works. Why is this? I'm using an up-...
48 votes
3 answers
2k views

How to implement (low-level) arrays in TeX

Update: I have revised my question based on the comment by Bruno Le Floch and some further research. As some may know, I'm implementing a huge TeX macro package which has to do a lot of internal ...
1 vote
2 answers
78 views

How to expand a token defined with \let

At the end of the following code, the token list will contains the token \val and not the character a as confirmed by the \showthe. Using a \def instead of a \let gives the result I want but is not an ...
0 votes
0 answers
28 views

Convert 1 column to 2 column item

How can I make number 1 single column like number 2 double column? 1 and 2 both of numbers are in the attached image. I have tried to find this solution but did not get any solution.
0 votes
1 answer
85 views

How to obtain absolute path of a file

Many languages provide functions to obtain the absolute path of a file. I wonder if Tex/LaTex has also such macros. In the following example, given a file name, test if this file really exists. Then, ...
0 votes
0 answers
30 views

How to check if different file path refer to the same file

A file may be accessed by different paths. For example, - subpath/myfile.tex - ./subpath/myfile.tex - ../current path/subpath/myfile.tex, - /d/.../current path/subpath/myfile.tex They refer to ...
30 votes
3 answers
4k views

What does \do do?

I saw some code using \do and I would like to understand it, which to me means finding out what exactly \do does. However, I haven't been able to find it in any sort of reference manual, and it is, ...
0 votes
0 answers
25 views

Variable distance between header and table

I'm using a great calendar generator latex-calgen by Simon Gerber. It combines python and LaTeX to generate a pdf file with a calendar. Each month is on a separate page and every page has a header on ...
75 votes
4 answers
3k views

Advantages and disadvantages of fully expandable macros

As I currently understand them, fully-expandable macros are analogous to pure/effect-free functions in functional programming. Correspondingly, things that are not expandable, such as \def, are ...
1 vote
1 answer
18 views

help with latex syntax parsing errors

Could anyone help to fix the syntax parsing error ? \documentclass{article} \usepackage[utf8]{inputenc} \begin{document} \begin{aligned} \rho &= \begin{pmatrix} ae^{i\...
23 votes
10 answers
764 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 ...
2 votes
3 answers
156 views

Get \string-ification of first opening brace in argument?/Get \string-ification of first opening brace's matching closing brace in argument?

Can you write a LaTeX macro where the output is the result of applying \string to the argument's first character token with category code 1 which is not a control-sequence-token and not an active ...
1 vote
1 answer
42 views

How does \special know which output driver it's addressing?

The TeXbook says that \special{…}is a special instruction to the output driver. But how do you know when you write the instruction which output driver will be reading it?
27 votes
5 answers
2k 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 ...
7 votes
1 answer
219 views

Maximum amount of characters per line in .tex-input files?

According to TeXbook TeX does preprocess files of .tex-input line per line (converting all characters of the line to TeX's internal character-representation-scheme (ASCII or Unicode), truncating ...
8 votes
1 answer
128 views

Why is \unexpanded not respected after an \if?

I was surprised to find that the argument of an \unexpanded is expanded if the \unexpanded is within the first two tokens after an \if. Using Knuth TeX's \noexpand instead works but I am curious where ...
193 votes
10 answers
25k views

Why is LaTeX so complicated? [closed]

I have been using LaTeX professionally almost every day for almost 10 years, so I think I can say that, by now, I more or less know what I'm doing. I also do a lot of ordinary computer programming, in ...
9 votes
5 answers
298 views

How to safely check by means of expansion-methods whether a list of tokens contains a token which is defined in terms of \outer?

I take the following question for a moot thing. Nonetheless it makes me sick that I don't see a good and robust solution myself. ;-) Assume something like this: \def\unfold{\umbrella My bald head ...
32 votes
7 answers
10k views

Test whether token register is empty

Is it possible to test whether a token register is empty without expanding it?
0 votes
0 answers
47 views

How to make always visible the tooltip content on SumatraPDF?

i am created a package for tooltip using Tooltip that works with all pdf readers. Here my TeX code below \documentclass{book} \usepackage[intlimits,tbtags]{amsmath} \usepackage[utf8]{inputenc} \...
0 votes
1 answer
30 views

code fails to be wrapped with condition

In the following example, I want the content in minipage is highlighted by \colorbox if the condition is true. If the condition is false, the content in minipage typeset directly. The typeset of true-...
10 votes
1 answer
276 views

How do I define a new TeX register with arguments in LuaTeX?

Some time ago I tried to implement the \pdfadjustinterwordglue from pdfTeX in LuaTeX using a callback. Getting the callback to work is pretty simple, but there is another major problem in the way ...
1 vote
1 answer
26 views

Expansion rule for a character redefined with `\newunicodechar`

Consider the following code. With xelatex or lualatex, it produces three identical results. However, with pdflatex one shall get an error. The main "macro" is a Unicode character ᵢ, defined ...
15 votes
3 answers
2k 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 ...
4 votes
1 answer
121 views

\let equivalent in LaTeX2e

I have read in the official LaTeX2e for class and package writers guide (section 2.7.2 "Make it robust") that one should aim to use as many LaTeX commands as possible. As an example, they ...
3 votes
3 answers
178 views

How to extract text from argument

The following code tries to extract plain text from formatted argument(here is \bfseries) and fails. \x is used to store the expansion result of \pgfkeysvalueof. \edef is for fully expansion of \...
3 votes
0 answers
115 views

Could TeX run Doom?

I know this question sounds silly, but Doom has been made to run in all sorts of completely ridiculous environments, including text-based terminals. So how about TeX? Could it somehow run Doom? I know ...
-1 votes
0 answers
93 views

How does a TeX engine process the informations within a .tex file?

I want to write a LaTeX-TeX parser to manipulate .tex files for a program. I found this question here How does a TeX engine read and render the input stream? which explains how everything works under ...
-1 votes
0 answers
40 views

Can LaTeX-TeX be described with EBNF grammar? [duplicate]

This question is related to the question I asked here How does a TeX engine process the informations within a .tex file?. I want to write a program to parse TeX-LaTeX files. I found libraries to write ...
42 votes
5 answers
3k views

How does your mind bend \expandafter to its will?

Expansion is often cited as one of the most arcane aspects of TeX, more akin to witchcraft than to something easily picked up by the newcomer. There are many great questions and great answers about ...
1 vote
0 answers
71 views

Get page edges coordinates in Metapost and ConTeXt

I have written several macros for my projects using TikZ. Several of them need to be aware of the page edges and margins. For example, this is a small macros I have written to draw rectangles from the ...
3 votes
1 answer
103 views

How do I make a character active only in text mode?

I want to make the character > active only in text mode (to create markdown-style block quotes) but not in math mode. I know the \mathcode`>="8000 way to make a character active only in ...
10 votes
1 answer
387 views

New primitives that weren't part of TeX

This answer contains the statement: It requires a current tex system (texlive 2021 or a current miktex) as it needs some new primitives. Do newer tex systems add primitives that weren't already part ...
1 vote
0 answers
124 views

What are the boundaries of TeX?

Does TeX have a limit at all? I've seen in forums that besides rendering objects with pgfplots and tikz, to animating with animate, to interactive PDFs by embedding Javascript in TeX, actually nothing ...

1
2 3 4 5
37