# Tag Info

5

I have the same problem regarding page number in documents, and found several solutions. By borrowing some code from Ulrike Fisher’s answer to this question I was able to defining this macro: \documentclass{article} \usepackage{lipsum,ifthen} \usepackage[lastpage]{zref} \makeatletter \zref@newprop*{numpage}{\the\value{page}} \zref@addprop{main}{numpage} ...

5

Instead of lastpage you can use totcount package. \documentclass{article} \usepackage{lipsum} \usepackage{etoolbox} \usepackage{totcount} \regtotcounter{page} \begin{document} \ifnumcomp{\totvalue{page}}{>}{1}{\pagestyle{plain}}{\pagestyle{empty}} \lipsum[2] \end{document} This will take 2 compilation runs to settle down.

5

I'd just use a "helper" macro so the \savedstyle can be expanded (once): \documentclass[varwidth,border=5]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \newcommand{\misdirection}[2][]{% \begin{tikzpicture} \node (tree) at (0,0) {tree}; \node (apple) at (3,0) {#2}; \draw [blue,#1] (tree) -- (apple); ...

4

Indeed in \SetQuestionProperties{ section-title = \secName } the macro \secName needs to be expanded once. Otherwise the question property section-title is set to the token \secName it is only expanded when used in \printsolutions where its current definition is Answers (which is what you're seeing in your example). A usual way to expand a token before is ...

4

With expl3, just for fun :) \documentclass{article} \usepackage{xparse} % automatically loads expl3 \usepackage{tikz} \usetikzlibrary{arrows.meta} \newcommand{\misdirection}[2][]{% \begin{tikzpicture} \node (tree) at (0,0) {tree}; \node (apple) at (3,0) {#2}; \draw[blue,#1] (tree) -- (apple); \end{tikzpicture}} \ExplSyntaxOn % Declare our ...

4

When you've got a shell command which creates plot1 in shellout.tex file, then you can simply modify this shell command in order it creates \includegraphics{plot1} instead simple plot1 in the shelloupt.tex file. And you can simply use \input shellout But if you insist on the idea that your shell command creates only plot1 in your shellout.tex file then ...

4

Here is a common solution without any expl3, etoolbox etc. The \and macro can be defined as required. We need only three lines of macros: \def\mylist#1{\mylistA #1\and\and} \def\mylistA#1\and{\ifx\and#1\and\else \and{#1}\expandafter\mylistA\fi} \def\and#1{$\underline{\rm #1}$ } \mylist{Element1 \and Element2} Edit: Egreg's comment here includes question, ...

3

The problem is that \define@key doesn't expand its argument; also \index should be expanded at definition time in the replacement text of \define@key, not at runtime. Using \index is not necessary, \the\count@ does the same (or \@arabic\count@, if you prefer. And \index is a badly chosen name anyway: try building an index for your document to see why. ...

3

This is an “illegal” answer, as the code I propose relies on defining a variant of an internal command. The answer is so mainly aimed to give ideas to the package developer. I define a command \DeclareQuestionPropertyFixed that takes as arguments a property name and the variable from which the value should be obtained from, in this case ...

2

It's not very clear what you want to achieve, but here's a definition for \appendcmdto and \xappendto; the latter does complete expansion on the third argument. \documentclass{article} \newcommand{\appendcmdto}[3]{% \edef#1{% \unexpanded\expandafter{#1}% \space \expandafter\noexpand\csname #2\expandafter\endcsname ...

2

If the file shellout.tex just contains one line with the file name of the generated file, then \usepackage{catchfile} \newcommand{\includeplot}[2][]{% \immediate\write18{python pytexplot.py #2}% \CatchFileDef\plotpath{shellout.tex}{\endlinechar=-1 }% \includegraphics[#1]{\plotpath}% } in the preamble, with \includeplot{plot1} in the document or ...

1

[moved from a comment] Just to provide additional context to already given answers: You can not, in general, hope to pass to some LaTeX command expecting something like a filename, a macro as argument; at best (and not always) the command will be of the type which attempts to expand its argument, and as soon as this argument does unexpandable things, it ...

1

Here is a workaroud. All \input{<name>} are replaced by the file contents in the spreadtab environment: \documentclass{article} \begin{filecontents*}{products.tex} @ Plant & 60 & 2 \\ @ Book & 90 & 4 \\ @ Other & 100 & 10 \\ \end{filecontents*} \usepackage{spreadtab,booktabs,xpatch} \makeatletter ...

1

If you are not bound by the idea to limit items by \and you may want to take a look at the packages commado or dowith that I recently discovered when having a similar problem. With the former you could try something along the lines \usepackage{commado} % ... \newcommand{\myList}[2][\underline]{\doWithCSL{#1}{#2}} and call it like ...

1

Here's how to do it without expl3: \newcommand\freezeStyle[1][]{% \pgfqkeys{/demo}{#1}% \expandafter\edef\csname\savedname\endcsname##1{% \noexpand\misdirection[\savedstyle]{##1}}} Note that \edef is used here and \noexpand is used to protect macros that should not be expanded. \typeout{\meaning\helloMom} macro:#1->\misdirection [execute ...

1

(don't redefine \value in LaTeX but...) \def\contents{Files:} \def\value{yo man} \def\tmp{\appendcmdto{contents}{section}} \expandafter\tmp\expandafter{\value} This is assuming \appendcmdto is defined somewhere (your question didn't make that clear) or just \makeatletter \def\contents{Files:} \def\value{yo man} ...

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