New answers tagged

4

From The TeXbook (my emphasis): [. . .] they are defined in terms of muglue, a special brand of glue intended for math spacing. You specify muglue just as if it were ordinary glue, except that the units are given in terms of mu (math units) instead of pt or cm or something else. As requested, also from The TeXbook: ...


7

This is an interesting mathematical question. The number two hundred seventy-five can be represented in different ways: 275 in decimal notation with “Western digits”, ٢٧٥ in decimal notation with “Arabic digits”, CCLXXV in Roman numerals, 113 in hexadecimal digits, 100010011 in binary digits, and many others (it's duecentosettantacinque in Italian). When ...


13

\thecounter typesets the result of the counter, be it in arabic, roman, etc, while \value{counter} provides an integer value in return. In many, but not all, instances, the difference will go unnoticed. The rule is, if you are looking for a character, use \the...; if you are looking for an integer, use \value{...}. Here's an example where it matters. By ...


2

\mskip and \thinmuskip are TeX primitives, so they have no definition: they are part of TeX. If you want to have multiples of \thinmuskip, you can do as follows. \newmuskip\normalnegthinmuskip \normalnegthinmuskip=-\thinmuskip \catcode`@=11 \def\!{\afterassignment\makenegthinmuskip\count@=0} \def\makenegthinmuskip{\mskip\ifnum\count@=0 \else\count@\fi\...


2

\thinmuskip is set to 3mu by default in fontmath.ltx which is read in while the format is being made, the last few lines of which are: \thinmuskip=3mu \medmuskip=4mu plus 2mu minus 4mu \thickmuskip=5mu plus 5mu \endinput %% %% End of file `fontmath.ltx'. So you can use \thinmuskip=5mu to have a bigger default or to set an arbitrary value something like $a\...


5

The tex syntax for a numeric literal are 123 % decimal "12A % hex '327 % octal `@ % character value (= 64 here) `\@ % same as above so \catcode`@=11 is the same as \catcode 64=11 and sets the catcode of character code 64 to 11, which has the effect of making @ a letter.


5

This is a ligature in the font the same mechanism that changes two f to an ff ligature, so it is not under the control of TeX and you would need to adapt the font metrics.


4

You could use \@for or an expl3 list but often a more convenient (and a lot more efficient in terms of expansions) technique is to use a different structure which allows you to execute the list with no separate loop macro, this is explained in appendix D of the texbook and used in several places in latex (look for \@elt usage) I'll use \\ here. \...


8

A more “primitive” way in LaTeX, that also avoids the issues with grouping one gets with \foreach, would be \makeatletter \def\basiccolors{% black,blue,brown,cyan,darkgray,gray,green,lightgray,lime,% magenta,olive,orange,pink,purple,red,teal,violet,white,yellow% } \def\do@def#1{% \expandafter\newcommand\csname command#1\endcsname{% \textcolor{#1}{...


7

In Linux you can print all processes from within your document and grep the relevant line. The output of this command can be printed to the document. Adapted from Write18: capturing shell (script) output as command/variable?: \documentclass{article} \begin{document} Command used is {\catcode`_=12 \ttfamily \input{|"ps aux|grep -Eoh '[a-z]+latex.*\jobname.*'...


3

As an example you gave: \tokenstomacro{\one#1\two#2\three#3\four#4\five}% → \macro=macro: ->1##112##2123##31234##412345. What about \tokenstomacro{\string#}% ? Shall expansion/stringification take place before hash-doubling? Shall expansion/stringification take place after hash-doubling? That makes a difference. In the further case \macro ...


5

With an “extended” TeX engine (not with Knuthian TeX), \newtoks\mytokenregister \def\five{\four5} \def\four{\three4} \def\three{\two3} \def\two{\one2} \def\one{1} \def\tokenstomacro#1{% \mytokenregister\expandafter{\expanded{#1}}% \edef\macro{\the\mytokenregister}% } \tokenstomacro{\one#1\two#2\three#3\four#4\five} \show\macro \csname stop\endcsname \...


11

Just for completeness: (La)TeX does have something that is equivalent to <>: \unless\ifnum#1=#2. \documentclass[]{article} \begin{document} \unless\ifnum1=0 1 is not equal 0. \else 1 equals 0. \fi \end{document} In this case it does not make things shorter or simpler, but sometimes this helps making the code easier to understand.


18

\if compares two tokens, independently of what they mean. The test \if 1<>0 compares 1 and < and yields false, thus you see 1 equals 0. For the sake of the example, if you had, \if 11<>0 then the test would be true because TeX would compare 1 and the next 1 and would return true. Then the test: \if 11<>0 11 is not equal 0. \else 11 ...


2

The safest way is probably to use an inline heading eg the following which puts Zzzzz into the start of the following paragraph and then cleans up \everypar it does this in a way that works even if the paragraph starts in a group, as here. \documentclass{article} \begin{document} \paragraph{Zzzzz} \showthe\everypar {abc} {abc} \end{document} ...


1

As explained in the comments, TeX doesn't know about strings but only about expandable and executable macros and primitives. When TeX processes its input it starts expanding tokens as far as necessary to find an unexpandable command with its parameters or output characters. It then starts executing those if they are commands, or adds them to the built page ...


6

Without LuaTeX it's not possible. Internally TeX knows how to write to the terminal only, but it does not provide this option at the macro level. A bit of context: TeX represents files using two arrays: write_file, a pointer to the output stream and write_open, a boolean which tells TeX whether the stream is connected or not to an actual file. The ...


Top 50 recent answers are included