# Tag Info

18

For example, the switch \ifv@ can be split into two switches for the height and depth: \ifv@ht@ and \ifv@dp@. The the macros are changed in this way (unchanged macros are commented): plain TeX % \newif\ifh@ \newif\ifv@ht@ \newif\ifv@dp@ \def\vphantom {\v@ht@true \v@dp@true \h@false\ph@nt} \def\hphantom {\v@ht@false\v@dp@false\h@true \ph@nt} ...

13


9

A control sequence can't have two meanings at the same time. When you do \newcount\i you simply lose the dotless i. Fix (with some % at end of lines): % This accent macro works. Spelled out: r\'{\i}os % It also works inside another macro. \def\rios{r\'{\i}os} Macro: \rios % When I make a quasi-array by hand it works. \expandafter\def\csname ...

7

The subcaption package delays the definition of subfigure and subtable when executing the \AtBeginDocument hook. So the error is because \newenvironment{subfigure} wants to define an already existing environment. Indeed, you get exactly the same error if you use \NewDocumentEnvironment. If you do \AtBeginDocument{% ...

7

\pdfmdfivesum also works on arbitrary strings: \pdfmdfivesum{Hello World} Result: B10A8DB164E0754105B7A99BE72E3FE5 The hex string can be decoded to save space: \pdfunescapehex{\pdfmdfivesum{Hello World}} \pdfmdfivesum is expandable and can be used inside \edef. \pdfmdfivesum works on file only, when the keyword file is given: \pdfmdfivesum file ...

6


6

You want \string# in the \write but to refer to # in the body of a definition you need ## so \string##

6

\uppercase is not expandable. Therefore it does not expand inside \csname, which then chokes on \uppercase in the name. Also \expandafter\def\uppercase cannot expand \uppercase, thus \expandafter has no effect and the remaining \def\uppercase would change the definition of \uppercase. There \uppercase should be given outside: \def\makecs#1#2{% ...

5

There is no need to write #1 at all, because the argument of the new defined macro gets at the end of the definition text as last argument of \hyperlink. Then the new command can be defined without arguments and the argument in the input is later taken by \hyperlink directly. There are lots of (unwanted) spaces by line ends. I have added ...

4

\documentclass{memoir} \newwrite\testaux \immediate\openout\testaux=\jobname.myaux \begin{document} \makeatletter \immediate\write\testaux{\string\dont@want@spaces@after@this words} \immediate\write\testaux{\string\dont@want@spaces@after@this@either words} \makeatother Here is a body. \end{document}

3

I guess you want to use \pdf@strcmp: \documentclass{article} \usepackage{pdftexcmds} \def\myoldvalue{emptystart} % initialize \makeatletter \newcommand\foo[1]{% \texttt{\string\myoldvalue}: \myoldvalue\\ ARG1: #1\\ \ifnum\pdf@strcmp{\myoldvalue}{#1}=\z@ TRUE% \else FALSE% \fi \par \gdef\myoldvalue{#1}% } \makeatother \begin{document} ...

3

Always post fully compilable examples: This compiles just as expected \documentclass[a4paper]{article} \newcommand*\mycmd[3]{#1 & #2 & #3 \\} \begin{document} \begin{tabular}{ccc} \mycmd{a}{b}{c} \mycmd{d}{e}{f} \end{tabular} \end{document}

2

With forest, you can easily specify complex sub-trees, format them in different ways and mix explicit and automatic node creation within your tree. And you can do all this very concisely and without needing to worry about expansion issues. (At least, usually not.) For example: \documentclass[tikz,border=5pt,multi]{standalone} \usepackage{forest} ...

2

Thanks to the comments to my original question I was able to figure out a solution to my problem. However, I'm not sure if it is really appropriate. It works, but maybe there is a better solution? \NewDocumentCommand\mycommand{o o m m}{ \ifthenelse{\equal{#1}{hello}} {hello} {not hello} \ifthenelse{\equal{#2}{world}} {world} ...

2

I use a similar command using xparse for setting languages: \DeclareRobustCommand{\setlanguage}[1]{% \IfEq{#1}{da}{% \renewcommand{\contentsname}{Indhold} % TOC Name }% {}% if not, then do this }% In the document, you would use: \setlanguage{da} % or some other ISO 639-1 code Also see ...

2

This doesn't extend the existing \vphantom definition, but provides an alternative. It works in text mode as well as all styles of math mode. EDITED to remove package dependence on scalerel, but the \thisstyle and \savedstyle definitions that remain largely mimic those from the package (\ThisStyle and \SavedStyle). EDITED to add \wdphantom, \htwdphantom, ...

2

Like this? You added \input at the wrong place, inside \linemark is where it should be. \documentclass{memoir} \usepackage[spacing, tracking]{microtype} \usepackage{libertine} \usepackage{xcolor} \usepackage{xspace} \nonfrenchspacing \microtypecontext{spacing=nonfrench} \newcounter{srcline} \newcommand{\linemark}{\stepcounter{srcline}% ...

1

\protected@edef (see Steven’s answer), however, won’t inihibit the expansion of commands not declared as robust, unless you explicitly \protect them inside the replacement text. The following, trivial alternative \documentclass{article} \newcommand*{\mycmd}{% \edef\tmpcmd{\noexpand\textit{test}}% \tmpcmd } \begin{document} \mycmd \end{document} is ...

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