Tag Info

New answers tagged

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 ...


0

Try the ifmtarg package. For instance (less any typos): ... \usepackage{ifmtarg} \makeatletter \newcommand{\isempty}[1]{% \@ifmtarg{#1}{YES}{NO}} \newcommand{\isnotempty}[1]{% \@ifnotmtarg{#1}{YES}} \makeatother ... then some results are: \isempty{} --> YES \isempty{ } --> YES \isempty{E} --> NO \isempty{ E } ...


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 ...


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 ...


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 ...


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 ...


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.


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 ...


0

First \nointerlineskip is not necessary, because it follows \hrule; third and fourth \nointerlineskips are not necessary, because they follow a kern. Also, there is a slight catch here: we must add width \hsize to first and fourth \hrule, lest top and bottom rules extend out of page boundaries (because of \moveright \hsize ... + width 0.4 pt of right margin ...


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.


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 ...


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

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 ...


0

You could use \overbrace and \underbrace: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} \overbrace{a}^{\text{output}} = \underbrace{b}_{\text{significant}} + \underbrace{c + d}_{\text{non significant}} \end{equation} \end{document}


0

In both cases, if the argument found in this way has the form '{}', where stands for any sequence of tokens that is properly nested with respect to braces, the outermost braces enclosing the argument are removed and the will remain. [...] I also want to add that I am less interested in workarounds than in the answer to the question in the title: ...


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

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 ...


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 ...


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 ...


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

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 ...


0

I'm getting Error Latex TeX capacity exceeded, sorry [input stack size=5000] in a beamer document when I try to make a block without a title and starting with an itemize environment: This fails: \begin{frame}{About Foo} \begin{block} \begin{itemize} \item foo \end{itemize} \end{block} \end{frame} This works: ...


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: ...


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 ...


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 ...


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


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 ...


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 ...


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 ...


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. ...


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 ...


6

The two settings control different behaviours. Setting -interaction=nonstopmode tells the TeX engine to run with minimal interaction with the user and as far as possible to 'go past' errors. It's therefore very useful in automation. Setting -halt-on-error tells the engine to stop processing the document at the first error, rather than trying to keep going. ...



Top 50 recent answers are included