Tag Info

Hot answers tagged tex-core

21

A macro is any control sequence (or active character) defined with \def, \gdef, \edef or \xdef. TeX macros support up to nine arguments, which contradicts your statement about it not having the notion of arguments to control sequences. The most common usage of arguments is in the “undelimited” form; say that you do \def\foo#1{--#1--} so \foo takes an ...

13

{} have two distinct uses in TeX, as grouping and to delimit macro arguments (when they do not form a group). Ignoring latex specifics and tests that make the argument optional, then \foo[arg1]{arg2}{arg3} is defined in tex primitives as \def\foo[#1]#2#3{something using #1, #2 and #3} so a use such as \foo[abc]{xyz}{123} then #1 is abc as the ...

12

Searching for \edef or \xdef (global variant) with command to be defined and argument in TeX Live 2015 and filtering out possible false positives (when the command is constructed with \csname): egrep -r '\\[ex]def\\[a-zA-Z@]+#1' texmf-dist/tex/ | grep -v '\\[ex]def\\csname' Result are 219 lines. I do not want to discuss all findings, thus I restrict ...

10

From the TeX Book (Chapter 13 Modes, p 86): Exercise 13.1: If you say \hbox{...} in horizontal mode, TeX will construct the specified box and it will contribute the result to the current paragraph. Similarly, if you say \hbox{...} in vertical mode, TeX will construct a box and contribute it to the current page. What can you do if you want to ...

10

The method of the question \bgroup \setbox0=\hbox{#1} \ifdim\wd0=0pt it is empty \else it is not empty \fi \egroup has several problems, if used for a general test: \setbox0\hbox{#1} leak color specials, when #1 contains top level \color commands, because the color macros use \aftergroup to reset the color after the current group (\hbox). This ...

8

The definitions of \B and \C are the problem: \def\B{\advance\cnt@a by-1} \def\C{\ifnum\cnt@a>0} TeX does not stop at the end of the numbers, but continue expanding until it finds a token, which is not a digit, e.g.: \B1234\relax will decrease \cnt@a by -11234, not by -1. Or \B\C Then the \ifnum is executed before the counter is decreased. Both ...

7

Curly braces An one-liner to remove the curly braces: \expandafter\def\expandafter\mycommand\mycommand Explanation: \mycommand contains {"/home/user/di rect ory/"/}. When the \expandafter commands have done their job, the following remains: \def\mycommand{"/home/user/di rect ory/"/} The curly braces are now used for the definition text. Quotes ...

7

No weird error, actually. The primitive \showthe expands tokens in order to find something good for being shown, the rules are the same as for \the. Since \nointerlineskip expands to \prevdepth -1000\p@ and \prevdepth is legal after \the when TeX is in vertical mode, the current value of \prevdepth is shown, which is -1000pt, because TeX is at the start of ...

6

In case you just wish to know whether the macro-argument in question consists of some tokens or doesn't consist of any token: As macro-arguments in any case are brace-balanced, Robert R. Schneck in june 2003 presented in the usenet-newsgroup comp.text.tex the idea of nesting the argument into a brace-group and then "hitting" it with \stringand then ...

6

The system dependent "end-of-record" is determined as explained in Carriage-return and line-feed in web2cTeX (at least in Web2C implementations). Now the rule explained on page 46 of the TeXbook applies: TeX deletes any ⟨space⟩ characters (number 32) that occur at the right end of an input line. Then it inserts a ⟨return⟩ character (number 13) at the ...

5

\hfilneg isn't a minus value but rather a negative plus value: \hbox to\hsize {\hskip 0pt plus 0pt A puzzle.\hskip 0pt plus -0pt} \hbox to\hsize {\hskip 0pt plus 10pt B puzzle.\hskip 0pt plus -10pt} \hbox to\hsize {\hskip 0pt plus 100pt C puzzle.\hskip 0pt plus -100pt} \hbox to\hsize {\hskip 0pt plus 1000pt D puzzle.\hskip 0pt plus -1000pt} \hbox ...

5

After a completely false understanding of the question, I have rewritten my answer to show how \edef with an argument can be used to "fix" the selected equation citation style. An \edef is evaluated at time of definition, whereas \def is evaluated at time of execution. If \edef\eqcite#1{} is used in preference to \def\eqcite#1{}, then changes to the ...

5

Here is an alternative expandable solution: it uses no e-TeX, no TeX conditionals, no \expandafter's, no \string's. it expands in three steps in all cases (with some usual \romannumeral0 wrapper one could get it to expand in two steps), which presumably makes it reasonably fast, it is entirely based on expansion of suitably delimited macros, but the ...

5

Here's an implementation in expl3: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \cs_new:Nn \georgian_ordinal:n { \int_compare:nTF { 1 < #1 < 21 } { me\mbox{-}#1 } { \georgian_ordinal_aux:n { #1 } } } \cs_new:Nn \georgian_ordinal_aux:n { \int_case:nnF { #1 } { { 1 }{ #1\mbox{-}li } { 40 }{ me\mbox{-}#1 } ...

4

There is a usage of \edef with parameter in special expansion control. One nice (yet quite complicated) example can be found in skeyval-core.tex v1.3 on line 1997 \skvrobustdef*\skvpopfunctions#1#2{% \begingroup \edef\skv@elt{\skvnoexpandcs{\skvremovescape{#1}@skv@stack}}% \expandafter\skvifdefTF\skv@elt{% \expandafter\ifx\skv@elt\@empty ...

4

Consider the following example: \showboxdepth=\maxdimen \showboxbreadth=\maxdimen \tracingonline=1 \baselineskip=12pt plus 2pt \lineskip=3pt minus 1pt \lineskiplimit=2pt \setbox0=\vbox{ \hbox{\vrule height 5pt depth 3pt} % this has depth 3pt \hbox{\vrule height 5pt} % this has height 5pt } \showbox0 \setbox0=\vbox{ \hbox{\vrule height 5pt depth ...

4

In the first case you are just seeing box255, in the second case you are using the plain tex output routine and hooking into \shipout so you are seeing \shipout\vbox{\makeheadline\pagebody\makefootline}% and the extra boxes you see are the headline and footline which are white because of \nopagenumbers but the box and glue structure is still there.

4

After an explicit ⟨number⟩, TeX looks for ⟨one optional space⟩ (with expansion) which is then ignored. Of two space tokens, only the first would be ignored, so \char"27 \space \char"27\space\space would give the desired result. Notice that the space is (looked for and) ignored also after an alphabetic constant, so it wouldn't help typing \char`\- cried ...

4

The two examples obviously produce different results, at least because the \hbox will be overfull in the first case and underfull in the second one. Example code \tracingonline=1 \showboxbreadth=\maxdimen \showboxdepth=\maxdimen \setbox0=\vbox{ \parindent=0pt \leavevmode \hbox to 0pt{\hskip -\parindent \bf 8.}% Lorem. }\showbox0 \setbox0=\vbox{ ...

3

One of my favorite tricks I learned, then stole, from Bruno Le FLoch is \slantbox, as described in his post at Shear transform a "box". This nominally will take an argument and using \pdf... magic, slant it to the right (positive slant) or left (negative slant) to an arbitrary degree. First, here is Bruno's magic code for your preamble: ...

3

Here's a LuaLaTeX-based solution. A LaTeX macro called \DeleteQuotes is set up, which removes all " characters from its argument. No assumption is imposed or required regarding either the location or the number of " characters in the argument of \DeleteQuotes. In particular, no difficulty arises if the argument of \DeleteQuotes contains no " characters at ...

3

The solution using \ifnums and using \variants{num}{list}{true-text}{false-text} macro which expands to the "true-text" if num is equal to the number in the list else it expands to the "false-text". \def\variants#1#2{\variantsA{#1}#2,,\end} \def\variantsA#1#2,{\ifx,#2,\expandafter\variantsE \else \ifnum#1=#2 \variantsC \else ...

3

I had my answer from August 24 deleted: It actually did not handle the request "if edition = 40,60,80,100,200,...1000 there is also prefix me-". Instead it handled the request "if edition > 21 and natural numbers k < 10 and l exist so that edition = k*(10^l), then there is also prefix me-". Thus, e.g., cases edition=30,50,70,90 were treated ...

3

EGreg had a nice answer on that, check http://tex.stackexchange.com/a/127506/65222 Here's the relevant part: A clever example of \if is for testing whether an argument is empty: \def\cs#1{% \if\relax\detokenize{#1}\relax The argument is empty% \else The argument #1 is non empty% \fi } It uses \detokenize which is an e-TeX feature. If ...

3

You need to use luatex (and access the box node from lua) or to typeset your paragraph in a vbox, not on the main vertical list so that you are in inner vertical mode, where \lastbox is allowed.

2

The \nopagenumbers is only active for the current group, which is ended at the end of the current paragraph. But the page is shipped out afterwards, so page numbering is again active. If you do the same thing in a paragraph which breaks over a page, you will get no page number on the page on which the paragraph begins: As any dedicated reader can clearly ...

2

There is a convention that even register (except count) numbers smaller than ten are free registers for local assignments, whereas odd numbers should only be used for global assignments. Mixing local and global assignments can cause memory trouble. Therefore I have multiplied the register numbers by two to get register numbers for local assignments. The ...

1

Create with the standalone document class a single pdf image of your grafic which you then include with \includegraphics into your main document. Crate a pdf and then use https://www.gonitro.com/de/ to convert the pdf into a Word format. There is a trial version.

1

First time I play with this kind of things, so probably it's not right. I let everyone correct this answer if he wants. A four liner. It's a completely expandable solution, and the \edef part is there to show two things: first, that it's completely expandable, and second, so that the \detokenize shows that the { and } are not in the result. ...

1

This assumes the format of the token list is {..."..."...} The \normalize macro receives as a mandatory argument the token list to normalize, possibly in “stored” form. The optional argument should be a control sequence that will receive the normalized string as replacement text (no check about it being defined is performed). If no optional argument is ...

Only top voted, non community-wiki answers of a minimum length are eligible