Skip to main content

Questions tagged [primitives]

{plain-tex} commands used for macro {programming}.

Filter by
Sorted by
Tagged with
1 vote
1 answer
76 views

Why does `\the\le` typeset `12820`?

TeX primitives reference says that the primivite \the can typeset a parameter value (integer, dimen, glue, or muglue) or internal quantity (except \font) produce a copy of the token list for a token ...
user615536's user avatar
6 votes
2 answers
1k views

Attempting to understand a piece of code I found

On this thread, I found a piece of code that I found really interesting and useful, but I have no idea how it works: https://tex.stackexchange.com/a/584979/261033 Here's the code in question, for ...
Tsskyx's user avatar
  • 115
11 votes
1 answer
215 views

Where do primitives for drawing come from?

I'm currently wondering how packages like tikz can possibly work. I've read the TeX Book and found no evidence of TeX primitives capable of drawing things. LaTeX is just a collection of macros so the ...
HomoVafer's user avatar
  • 294
2 votes
1 answer
131 views

"\show\ " outputs the "^^M" in TeX?

On page 10 of the book The TeXbook, it says that \show\cs, where \cs is any control sequence, can output its meaning. For example, \show\thinspace outputs > \thinspace=macro: ->\kern .16667em . ...
Y. zeng's user avatar
  • 2,105
3 votes
0 answers
81 views

How do you learn to read package documentation and LaTeX typesetting concepts like glue and boxes (primitives)?

I'm having trouble reading documentation from packages. It seems like there's something wrong with the way I'm reading them. How should I read them, in order to learn how to use the packages correctly ...
Adrik Ivanov's user avatar
3 votes
0 answers
149 views

General (dis)advantages of ways to define new commands

I have a question about the many ways to define a new command. I looked through the web and TeX.SE but couldn't find a complete answer (only some partly answers like, here, here, here, or here). I ...
lukeflo's user avatar
  • 1,597
0 votes
0 answers
24 views

Syntax of LaTeX macros [duplicate]

The TeX primitive \over has syntax {… \over …}. Is it possible to define a macro \foo, say, with syntax {…}\foo{…} without enclosing brackets?
Alois Pichler's user avatar
12 votes
2 answers
398 views

What does the new luatex primitive \deferred do?

I recently noticed that a new primitive, \deferred, was added to luatex (relevant texlive git changes). The luatex manual is austere in its examples and explanations for most things, and I see ...
mbert's user avatar
  • 4,506
5 votes
1 answer
140 views

Does XeLaTeX modify the \beginR premitive?

Consider the following code \TeXXeTstate=1 Hello World \beginR Hello World\endR \bye Which produce the following document with either XeTeX or pdfTeX Now, the out put of the following code is the ...
Udi Fogiel's user avatar
  • 4,479
9 votes
3 answers
483 views

\ignorespaces vs \relax

In the TeXbook, there is a macro called \ignorespaces: \ignorespaces ⟨optional spaces⟩. TeX reads (and expands) tokens, doing nothing until reaching one that is not a ⟨space token⟩. And there is ...
Stephen's user avatar
  • 4,454
1 vote
2 answers
97 views

Macro to define macros within .aux file is not working

Here are some macros that I am trying to define (based on this question): \odef{foo}{bar} will define an "object" with name foo and value bar. \objRef{foo} will insert the value of the foo &...
Ben Zelnick's user avatar
4 votes
1 answer
223 views

What are the differences between primitives/registers/macros/tokens?

I started learning LaTeX and these words appear a lot in both questions and answers. Do they all mean the same thing or are they different concepts?
ains94997's user avatar
4 votes
2 answers
354 views

A question about \ifcat in the TeXbook

In Chapter 20 of the TeXbook, Donald Knuth introduced the usage of \ifcat and he gave an example: For example, after \catcode`[=13 \catcode`]=13 \def[{*} the tests \ifcat\noexpand[\noexpand] and \...
Stephen's user avatar
  • 4,454
10 votes
1 answer
433 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 ...
Heiko Theißen's user avatar
5 votes
3 answers
188 views

Testing "sequentiality" of \expandafter (plain Tex) - weird results

Trying to have a better understanding/controlling over \expandafter, I wrote this code. \count100 = 0 \count101 = 1 \def\c{% \the \count100 \advance \count100 by \count101\relax}% % \everypar{\...
Daniel Bandeira's user avatar
0 votes
1 answer
176 views

How to use \newlinechar and \endlinechar primitives to output position information at the beginning and end of each line of text?

If I want to use the \newlinechar and \endlinechar primitives to output the position information at the beginning and end of each line of text, what should I do?
happy's user avatar
  • 159
0 votes
1 answer
187 views

MetaPost: mpost and plain.mp

Am I right that 'pure' MetaPost (mpost), without plain.mp, knows only primitive commands? So that MetaPost compiler + plain.mp is like a pure TeX + PlainTeX or TeX + any other macros package? Is it ...
Vladimir's user avatar
  • 589
1 vote
0 answers
49 views

How to output the name of a command at the same time when calling a command

I know that using everypar can print some information every time everypar command is called. I want to know whether it is possible to print the name of the command at the same time when the command is ...
happy's user avatar
  • 159
9 votes
3 answers
482 views

Syntax of TeX for primitives that demand braces

TeX defines some primitives which some of them expand (or try) the following tokens before execute itself; others even require argument between braces. But I couldn't get the point in this case. \...
Daniel Bandeira's user avatar
4 votes
2 answers
140 views

Statements about \noexpand in source3.pdf and in the TeXbook

The LaTeX3 sources, released 2021-07-12, says in section "23.7 Description of all possible tokens" of "Chapter 23: The l3token package /Token manipulation": Expanding \noexpand ⟨...
Ulrich Diez's user avatar
  • 29.7k
5 votes
1 answer
2k views

How to typeset ordered pairs?

I'd like to typeset ordered pairs with comma-separated components while \langle and \rangle as their delimiters. I want line breaks at commas for an ordered pair in inline math mode. So I came up with ...
KaiserKatze's user avatar
5 votes
2 answers
170 views

How to create a paragraph that show the number of line it contains?

Trying being brief... How can I create a paragraph that shows meta information, e.g., mentioning the number of lines or words it contains, using TeX primitives only? It's very important that such ...
Daniel Bandeira's user avatar
3 votes
2 answers
162 views

Redefine \pdfouput=1 to be ignored

How I can redefine the command \pdfoutput=1 to be ignored? I need to compile a file with lualatex (see https://tex.stackexchange.com/a/586129/33634) but it contains the command \pdfoutput=1. I cannot ...
Gabriele's user avatar
  • 2,003
1 vote
0 answers
53 views

Getting the name of control sequence token - which values of \escapechar besides 32 require special attention?

I'd like to get the name of a control sequence token as sequence of character tokens. With \relax I'd like to get relax. The preceeding escape character is to be removed from the result of \string\...
JamieLittleJoeHossAdamBen's user avatar
2 votes
4 answers
659 views

Minutes command in TeX

Someone told me, minutes were accessible in TeX, but I cannot find a command to call this. How do I call minutes in TeX? Please do not tell me about the construction of minutes out of \the\time, I ...
user avatar
4 votes
0 answers
141 views

What is the essential/crucial difference between \scantokens/\tex_scantokens:D and \tl_rescan:nn?

Part III The l3names package—Namespace for primitives, Section 1 Setting up the LaTeX3 programming language of interface3.pdf says: This module is entirely dedicated to primitives (and emulations of ...
Ulrich Diez's user avatar
  • 29.7k
5 votes
2 answers
142 views

Glue not needed in alignment templates?

Consider this simple alignment (note lack of \hfil in template) \halign{#&#\cr a&b\cr aaaaaaaa&bbbbbbbbb\cr } To my surprise, this does not give Underfull \hbox in alignment error! The ...
Peter Allenbach's user avatar
3 votes
1 answer
393 views

\vadjust example on Tug.org

I was on Tug.org reading about some of TeX's primitives. I came across this example usage of \vadjust. 1. \def\strutA#1#2{\vrule height#1 depth#2 width0pt} 2. \def\ta#1% 3. {% 4. \strutA{8.5pt}{3....
Harry's user avatar
  • 149
0 votes
1 answer
462 views

Multiple glossaries on a single page with a chapter-title

The setting is that I need to have two glossaries. They should be separated just by a \medskip and not by a \newpage-break. To stow them properly, I thought of putting them in a single chapter List of ...
Max's user avatar
  • 171
1 vote
1 answer
87 views

Why does unhboxing seem to ignore vertical mode and why does unvboxing seem to ignore horizontal mode?

First question Why does unhboxing seem to ignore vertical mode and why does unvboxing seem to ignore horizontal mode? The MWE after the next two pictures both delivers the text of the first question ...
Marsupial Wallaby's user avatar
2 votes
1 answer
68 views

The effect of triggering the re-writing/creating anew of a text file which currently is processed via `\input` puzzles me?

I tried to create a .tex-file fileb.tex which can be \input by filea.tex and which - when being input - stops being input and triggers rewriting itself. In my first attempts I erroneously omitted \...
Ulrich Diez's user avatar
  • 29.7k
6 votes
2 answers
175 views

Why does `\endinput` bring TeX into interactive mode while there are still tokens to process?

Minimal example consists of two files: fileA.tex: \def\foo#1{#1} \foo{\endinput\input fileB.tex}% fileB.tex: This is file B. \bye I assumed that compiling fileA.tex would lead to a file fileA.pdf ...
Jewdokija's user avatar
36 votes
1 answer
25k views

Difference between \hfil and \hfill

I am trying to understand the difference between \hfil and \hfill. I always thought that these commands were roughly equivalent except that \hfill was "stronger" than \hfil. As a result, I thought ...
user avatar
20 votes
1 answer
10k views

what is \kern good for

What is \kern instruction good for and how is it defined? I cannot find it in Knuth's book TeXbook.
user2925716's user avatar
  • 1,960
5 votes
1 answer
121 views

Get correct results for overwritten font identifier

How can I get a correct font identifier with \showthe and \the after it is overwritten? The MWE is below (Same result with all of Knuth TeX, pdfTeX, XeTeX, (e-)pTeX, (e-)upTeX and Aleph. Only LuaTeX ...
Hironobu YAMASHITA's user avatar
4 votes
3 answers
158 views

Overriding control sequences for accessing TeX's integer-/dimension-/glue-/..-parameters

In TeX there are a lot of parameters which you can adjust for changing the behavior of TeX. Example 1: By assigning \baselineskip=... you change distance between lines. Why TeX's breaking-paragraphs-...
Jevdokija's user avatar
1 vote
1 answer
190 views

What is "# Notation"? How does the # syntax work?

Closely Related: How to implement \expandbefore, similarly to \expandafter? In the related question, a reference is made to the "# Notation". How does the syntax work? From an answer on the other ...
elika kohen's user avatar
3 votes
1 answer
525 views

Different file opened by \openin (was: between 2017 and 2018)

Short version: It seems that some trivial behavior of file opening (\openin) changed between TeX Live 2017 and 2018 differs between environment. Only Overleaf one behaves differently. I did not see ...
Hironobu YAMASHITA's user avatar
21 votes
3 answers
2k views

Is there a list of expandable TeX primitives? LaTeX? e-TeX? others?

According to Christian Hupfer's comment I understood that calculations are possible in a keyval list when the macro is expandable. The macro \numexpr being expandable, calculations are possible. ...
AndréC's user avatar
  • 25.9k
1 vote
1 answer
314 views

TeX macro/primitive vs Plain TeX macro

I know there are TeX primitives and Plain TeX macros created (directly/indirectly) by TeX primitives. My question is are there TeX macro? E. g. I can use \break in pdfTeX without defining it and \...
John webner's user avatar
5 votes
1 answer
188 views

\string-primitive works in unexpected ways in LuaTeX -- Where can I find exact documentation of the \string-primitive in LuaTeX?

This question refers to LuaTeX-engines prior to luatex 1.10.0 in texlive 2019. With luatex 1.10.1 in texlive 2019 and later the \string-primitive works as expected. Where can I find exact ...
Ulrich Diez's user avatar
  • 29.7k
1 vote
1 answer
926 views

Changing text in Console output

I am finding that I am writing more and more packages/commands for other people these days and have started writing some nice default utility commands to use. However, there is always the concern for ...
Jason's user avatar
  • 949
3 votes
1 answer
931 views

Error of \begin{problem} ended by \end{problem}... huh?

So, I know if I get a mismatch error like error: \begin{problem} ended by \end{document}, that means I have mismatched number of \begin and \end commands. But here, I am getting the following error: !...
Jason's user avatar
  • 949
1 vote
1 answer
309 views

Swap many pair of command names in a row

I've learnt from this post how to swap two commands using the let primitive: \let\temp\first \let\first\second \let\second\temp \let\temp\undefined Now, in order not to flood my preamble with this ...
iago-lito's user avatar
  • 1,472
0 votes
0 answers
502 views

Conditional to execute alternative code when error detected

I would like to be able to build a conditional to execute one set of code if the conditional would compile, versus another if the code would generate an error. Take the following code block which ...
Jason's user avatar
  • 949
6 votes
2 answers
2k views

hide/show complete row of tabular

I need to toggle on/off full rows of a tabular via changing my preamble. My workflow only permits me to alter the first cell of each table in order to make it toggleable. My idea was to use the ...
sheß's user avatar
  • 3,692
15 votes
2 answers
2k views

What's the difference between \hfil and \hskip0cm plus 1fil?

What's the difference between \hfil and \hskip0cm plus 1fil? In both cases, a glue token is created that skips by zero, but with 1fil of stretchability. If you use \hbox spread 4cm{\hfil test \...
ChristianFigueroa's user avatar
3 votes
1 answer
120 views

How to test if a macro is being expanded between \csname ... \endcsname, in (e-)upTeX?

pdfTeX added some new primitives, based on e-TeX, including \ifincsname. When this primitive is being expanded between a pair of \csname ... \endcsname, the result of expansion will be true, otherwise ...
Ch'en Meng's user avatar
  • 3,853
11 votes
2 answers
41k views

How to fix the Underfull \vbox badness has occurred while \output is active on my memoir chapter style?

After some hours studying the warning Underfull \vbox (badness 2573) has occurred while \output is active on the question how to suppress "Underfull \vbox (badness 10000) ... while \output is ...
user's user avatar
  • 4,815
18 votes
2 answers
2k views

Documentation of \mathop

The Dirac delta distribution is ubiquitous in physics. Since it is a special object I wanted to give it some extra spacing by using \mathop. I know that single letters inside \mathop are centred ...
Henri Menke's user avatar