Tag Info

New answers tagged

2

This is similar to Why does \ifnum not work inside of TikZ style definitions?, but the situation is different. When processing label={...}, PGF looks for =; a workaround is thus hiding it: every node near coord/.append style={ label={ [black!80, label distance=-1ex] \ifnum\coordindex<1 ...


7

Edit OK as David pointed out in the comment, simply looking at \f@encoding/\f@family/\f@series/sc is not enough as this command is defined during a substitution. So one probably has to record if a substitution takes place: \documentclass[11pt,a4paper]{scrartcl} \makeatletter \def\define@newfont{% \begingroup \let\typeout\@font@info ...


3

The book class defines the \if@mainmatter conditional. So \if@mainmatter <we are in the main matter> \else <we aren't in the main matter> \fi is the scheme for the code you need. For instance \def\@LLview{% \if@mainmatter \pagestyle{LL}% \else \pagestyle{plain}% \fi } This indentation style is not mandatory, but I find it ...


3

You can't have \phantom inside \xdef, because it performs assignments. There are several strategies for avoiding the problem. First strategy: use a \protected macro: \documentclass{article} \usepackage{xstring,pgffor} \protected\def\Pzero{\phantom{0}} \begin{document} \def\result{} \foreach \i in {1,...,6}{% \StrChar{12345}{\i}[\c]% \ifx\c\empty ...


9

\phantom is a fragile command and not safe in an \edef. One way to locally make it safe is: \documentclass{article} \usepackage{tikz,xstring} \begin{document} \def\result{} \let\oldphantom\phantom \let\phantom\relax \foreach \i in {1,...,6}{ \StrChar{12345}{\i}[\c] \ifx\c\empty \def\c{\phantom{0}} \fi \xdef\result{\result\c}} \let\phantom\oldphantom ...


2

The Knuth's macro \newif is very cryptic. I spent full page 402 in my "TeXbook naruby" with explanation of this. But we can ask if there isn't more straightforward and more understandable solution of this task with equivalent result. I mean that it exists. For example: \def\newif#1{\expandafter\newifA\string#1\relax#1} \edef\tmp{\string\if} ...


5

Saying \newif\iffoo generates the following list of tokens: \count@\escapechar \escapechar\m@ne \expandafter\expandafter\expandafter\def\@if\iffoo{true}{\let\iffoo=\iftrue} \expandafter\expandafter\expandafter\def\@if\iffoo{false}{\let\iffoo=\iffalse} \@if\iffoo{false} \escapechar\count@ In what follows, spaces (or newlines) are added just for separating ...


10

working backwards: {\uccode‘1=‘i \uccode‘2=‘f \uppercase{\gdef\if@12{}}} % ‘if’ required \uppercase works on tokens and any token other than a character token is left unchanged. Character tokens produce new character tokens with the same catcode as before but with character code obtained by looking up the uccode (if that is non zero) so \gdef uppercases ...


5

No \ifx\\#1\\ with xparse: \documentclass{article} \usepackage{xparse,imakeidx,hyperref} \makeindex \NewDocumentCommand{\textindex}{om}{% #2% \IfNoValueTF{#1} {\index{#2}} {\index{#2|#1}}% } \begin{document} \textindex{Hello} \textindex[textbf]{World} \printindex \end{document} Explanation: the command \textindex has two arguments, one ...


3

The following example works fine: \documentclass{article} \usepackage{makeidx} \makeindex \newcommand{\textindex}[2][]{#2\index{#2% \ifx\\#1\\% % do nothing \else |#1% \fi}} \begin{document} \textindex{Hello} \textindex[textbf]{World} \printindex \end{document} If | is active, then \string helps: \string|% Note, that I have commented ...


1

From this source, I got a solution to my problem: \usepackage{etoolbox} \usepackage{refcount} \newcommand{\mypageref}[2]{ \ifnumequal{\getpagerefnumber{#1}}{\getpagerefnumber{#2}} {S. \pageref{#1}} {S. \pageref{#1}\ --\ \pageref{#2}} }


3

To understand what is wrong with your code, I'd add a \tl_show:n \cs_new_protected:Nn \mypkg_display_instrument:nn { \tl_show:n {#1} #2 \IfNoValueF {#1} {\\(#1)~(should~appear~only~if~"NoValue"~is~false) } } That will reveal that you are not getting -NoValue- as #1: you are getting \tl_mypkg_status. That's exactly what you'd expect from ...


1

Here is a mildly-automated version of your request using some magic from Order items in enumerate environment automatically: \documentclass{article} \usepackage{environ,etoolbox,multido} % Taken from http://tex.stackexchange.com/a/128318/5764 \makeatletter \newcounter{varoneitem}\newcounter{listcount}[varoneitem] \let\olditem\item% Store regular \item ...


2

Ulrike Fischer gave a hint about low-level \ifnum query, this version uses the \ifnumgreater macro from the etoolbox package (and provides a comparison). In my point of view, \VarOne should not be used as a macro but as a counter, as long only integer values are concerned. \documentclass{article} \newcommand{\VarOne}{1500} \usepackage{etoolbox}% ...



Top 50 recent answers are included