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

9
votes
3answers
362 views

Verbatim text in token registers

How can I add verbatim text in a token register (I want to accumulate pieces of code in a toks register and print them in an appendix). In the MWE below if you substitute verbatim text it fails. ...
9
votes
1answer
101 views

Interactively look up macro definitions

In a TeX document, the primitive command \show will print out the current definition of a macro one level deep (it won't (and can't?) reduce to primitives). This comes with the restriction of actually ...
9
votes
2answers
109 views

How can I specify text to be included in the pdflatex output log during compilation.

I would like to be able to have some kind of logging command that is able to log text to the default pdflatex logfile (<input-base-filename>.log). Is this possible, and if so, how? In ...
9
votes
2answers
172 views

Is it possible to use $ as a macro delimiter?

Experimenting with macro definitions that use strange delimiters (see e.g. this or this question), I thought it would be fun to have a macro that takes an argument of the form "a/b" and turns this ...
9
votes
2answers
670 views

Minimum length of last line of a paragraph

There is a more or less equivalent question to this: Ensure minimal length of last line, but I absolutely need a TeX solution. I more or less stumbled upon the problem mentioned in the discussion of ...
9
votes
2answers
240 views

Missing baselineskips?

Here are some cases where when there is stuff inside a vbox, the baselineskips are sometimes there and sometimes not. Or maybe it's something else that is producing the differences? \setbox0\vbox{% ...
9
votes
2answers
643 views

\def taking next word as argument?

This question is a variant of my previous question requesting a macro that takes the rest of the line as argument. I would like to write a macro that would take the next word as argument, where word ...
9
votes
1answer
136 views

What can and can't occur as macro argument?

The documentation of the environ package says The advantage to using environments is that their contents is not treated as a macro argument, so there are less restrictions on what can exist ...
9
votes
1answer
438 views

Computer Modern font with accented characters (in XeTeX)

I'd like to use Knuth's Computer Modern font with XeTeX in a way where I don't have to type accents in a \'-way and without any gimmick such as making accentuated characters active and then say ...
9
votes
1answer
668 views

Why \leaders and \mkern works strangely in different font size?

I can hardly determine a good title for this question, I'm sorry. Minimal test code: \documentclass{minimal} \usepackage{lipsum} \begin{document} foo {\fontsize{18}{18}\leaders\hbox{$\mkern ...
9
votes
2answers
219 views

Which spaces exactly are ignored by \halign?

Some spaces seem ignored by the \halign primitive. For instance, \setbox0=\vbox{\halign{ # \cr \space b \cr}} \showbox0 indicates that there is no glue before b, but that there are two spaces ...
9
votes
4answers
564 views

How do I get the category code of a character that is the value of a control sequence?

How can I get the category code of a character that is the value of a control sequence? If I do this The catcode for A is \the\catcode`A. I get The catcode for A is 11. If I do this \let\abc=A ...
9
votes
1answer
1k views

Newline/linebreak in \message

I want to prompt some messages to my console. I used \message{Hi out there!} Now i want some more Text but with an linebreak. \message{Hello World %some line break here Salut monde } Well i ...
9
votes
1answer
113 views

How can I create a better cryptogram environment?

I put together a macro that takes two arguments. The first argument is a string of letters which defines a cipher. The second argument is a message to be encrypted using this cipher. ...
9
votes
1answer
79 views

\centering breaks fragile command (is there a fix?)

Many on this site know (and perhaps find slightly annoying) that I will try to solve any LaTeX problem with the use of my stackengine package. My motto is like one of the overnight delivery services: ...
9
votes
1answer
991 views

Expansion in \numexpr…\relax versus \pdfstrcmp

The \numexpr...\relax construction in eTeX allows to evaluate numerical expressions, and it expands tokens fully as it goes. The \pdfstrcmp{...}{...} construction in pdfTeX lets us compare two lists ...
9
votes
1answer
626 views

Trapping LaTeX error/warning

Is there a way to trap an error/warning in LaTeX during compile time? I'm thinking of something similar to the VB script On Error Goto <blah>, but this time for LaTeX in something like ...
9
votes
1answer
805 views

Handling \ifnum's “! Missing number, treated as zero.”

Let's say I have a variable, which may - or may NOT - be a number; how can I handle the cases when it isn't a number, without crashing with "! Missing number, treated as zero." ? In practical terms, ...
9
votes
1answer
302 views

Making a range macro

Having syntactic sugar for ranges can be useful in programming languages. For example in Ruby, one can use a range by (2..10).map {|elem| elem + 1} to get an array consisting of each element in the ...
9
votes
1answer
241 views

How can I make a PDF of the source of pdftex?

I got the files tex.web and pdftex.web from the texlive svn repo. I ran weave tex.web pdftex tex.tex which produced a file tex.pdf with a nicely typeset, cross-referenced listing of the WEB source ...
9
votes
2answers
199 views

Hooks into mathmode

Short version Is there a way to pipe every symbol in a math environment unevaluated to an external program w/o manipulating the (La)TeX file directly (except for adding header files) or patching TeX ...
9
votes
1answer
124 views

Why does the list of recent contributions contain exactly two boxes?

In the transcript of \nonstopmode \tenrm \vsize=2cm \output={\shipout\vbox{ \showlists \unvbox255 }} \hbox{blah} \hbox{blah} \hbox{blah} \hbox{blah} \hbox{blah} \hbox{blah} \hbox{blah} ...
9
votes
1answer
203 views

Parsing a file name

What is the precise syntax for file names in various common distributions? This is relevant for three primitives: \input<filename> (renamed \@@input in LaTeX) \openin<4-bit ...
8
votes
4answers
263 views

Does macros get applied to the source code before compilation?

I wonder if this is true. The latex compiler first run though the document, and search for all the macro declarations. the compiler then go though the document, apply each macro as a string ...
8
votes
4answers
400 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 ...
8
votes
2answers
200 views

What is wrong with this TeX macro

Still soldiering on with trying to learn these macros. Can someone tell me why this isn't working? The macro \mycline{n-n} is supposed to expand to \cmidrule{1-1} ... \cmidrule{n-n}, but in my code ...
8
votes
6answers
901 views

Function like macro?

If you have programmed in a high level programming language, you must be familiar with the concept of functions, subroutines which return a value. For example, if you write in C, you can write a ...
8
votes
1answer
283 views

Can I make TeX completely free-form?

I'm bothered about the language format of TeX. I mean I want to know why the CR is converted into a space and % must be at the end of a line to avoid the matter. To make matters worse, a blank line ...
8
votes
2answers
479 views

Force the expansion of a macro parameter without \edef or \xdef

Two days I am looking for a solution but I have no more idea. This is my problem. I'm trying to create a macro to automatically define new other macros to write references in a document. I want to ...
8
votes
2answers
688 views

Selecting optical size?

For some time I've seen LaTeX-produced documents that had slight differences in fonts. When you looked at them, they had the same Computer-Modern or Latin-Modern, however, they looked more stylized ...
8
votes
3answers
1k views

How to make a ruler

In The TeXbook (Ch. 10, after exercise 10.3), DEK shows some nice rulers. But I couldn't figure out how he did them. I'm sure I could look it up from the texbook source, but for some reason I'm ...
8
votes
3answers
447 views

How to make a plain TeX conditional which checks if some specific numbers are present?

I need to make a simple conditional in a macro. If #1 is "1", "2", "3", "4", "5", or "6", then print Text: #1, otherwise, do nothing, even if it is empty. I tried this code: \ifnum#1=1 Text:~#1 ...
8
votes
2answers
372 views

Checking whether a file is empty?

Well, the obvious way to do that is with \ifeof, but for some reason, I cannot do this right. I wrote \newread\reader \openin\reader=empty \relax \ifeof\reader\message{empty}\else\message{not ...
8
votes
1answer
148 views

Which commands exist to define new commands?

Which commands are there that one can use to define new commands in (La)TeX? There are: \let, \def, \[re]newcommand[*], \DeclareRobustCommand[*], and ...? (And I've seen things like ...
8
votes
3answers
169 views

Questions on macro writing in TeX to modify an existing style file: fancybox.sty

I've decided that I must become more adept at TeX if I'm to become proficient with LaTeX. While this is probably obvious to most readers who pass by, my ability to muddle through has hidden this small ...
8
votes
2answers
155 views

Is it possible to remove (or otherwise nullify) a whatsit node from a box?

I am aware that it is not generally possible to modify the contents of a box (as per http://tex.stackexchange.com/a/49903/17427), though I believe it is sometimes possible to "unbox" material and hack ...
8
votes
2answers
253 views

Normal \relax vs. frozen \relax

With \edef\x{\ifnum0=0\else\fi} being \relax and with \def\y{\relax} we see that \ifx\x\y is false. Why? See also \ifcsname when it isn't apparent that the command is \relax'ed.
8
votes
2answers
167 views

Execute non-expandable code inside a tabular environment

As there is no Expandable version of \InputIfFileExists or \IfFileExists, the question arises whether it is possible to execute non-expandable code in a tabular environment after all: File main.tex: ...
8
votes
2answers
110 views

\setbox containing maths interferes with surrounding math mode in XeTeX

I encountered what might be a bug in XeTeX (but I would be glad to be proven wrong) while chasing a strange interaction between bytefield, unicode-math, and mathtools. In general, I do not expect a ...
8
votes
2answers
215 views

Practical uses for skips with negative stretch or shrink components

I am currently looking somewhat carefully at how TeX manipulates skips, and I am having trouble finding practical use cases for skips with a negative stretch or shrink component, such as \Askip and ...
8
votes
3answers
265 views

Detecting catcode in parameter text

Say someone has defined \documentclass{minimal} \begin{document} \def\fooA#1@{} \makeatletter \def\fooB#1@{} \end{document} It is easy to test and see that the two are different: ...
8
votes
2answers
152 views

Commands that disable everything except the counters

what I'm looking for... I'm looking for a couple a commands, \disableAllButCounters and \enableAll that would do the following: Everything between \disableAllButCounters and \enableAll would ...
8
votes
2answers
153 views

Are \count1, …, \count9 useful?

To quote TeX by Topic, "whenever a \shipout occurs, TeX also writes the values of counters 0–9 to the dvi file and the terminal." Do any dvi viewers or converters (e.g., dvips) make use of ...
8
votes
2answers
260 views

How do I redefine a macro when any group begins, then again when that group ends?

Okay, I know this is a pretty tall order, but I'm working on a package based on my answer here, and I'm including Ahmed Musa's environment which redefines \par. The problems are: Some environments ...
8
votes
1answer
75 views

Hyphenation of the word “paraboloid”

It seems like my TeX does not hyphenate the word "paraboloid" on its own. After adding \hyphenation{para-boloid} (I hope that's the right hyphenation...) to the preamble everything is fine. My ...
8
votes
3answers
1k views

How to hyphenate Portuguese in plain TeX?

I'd like to use plain TeX in Portuguese, but I don't know how to hyphenate in this language, or in any other language than English. What do I have to do?
8
votes
1answer
99 views

Cut last word from sentence one by one

I want to execute particular command for some space separated list as argument. And then execute the same command for the same list without last element and do it until list is empty. As extra point ...
8
votes
2answers
265 views

reversing the order of expansion

Is there a non-expl3 expandable function for reversing the order of expansion of an arbitrary number of tokens or macros? For example, \reverseexpansion<n>\a\b ...
8
votes
2answers
662 views

Reading the contents of a box

Is it possible to take a box and retrieve the following information from it: A list of all "top level" internal boxes; All intervening space (kerns and glue: did I forget another type of space?)? ...
8
votes
1answer
344 views

How to adjust the slant angle of a diacritic

I am trying to change the slant angle of an accent. I have used the fontdimen to adjust the quantity. The first portion of the code that follows adjusts fontdimen5 (the x-height). This works as you ...