Tag Info

New answers tagged

2

The standard TeX code for given task is: \def\something#1{\def\internal{#1}% \ifx\internal\empty the parameter is empty.\else it is nonempty.\fi } The problem of this code (above) is that the macro \something isn't expandable because it includes \def assignment. If you need expandable macro with the same test then you need to choose the token never ...


7

You can test macro-to-macro using \ifx. That is, \ifx<csA><csB><true>\else<false>\fi will test whether the definition of <csA> matches that of <csB> and execute <true>, or <false> otherwise: \documentclass{article} \makeatletter \newcommand{\@emptymacro}{}% Used to test against an empty macro ...


1

You can load the package scrextend with the option cleardoublepage=plain. To get an empty page right after the titlepage use \cleardoubleoddemptypage after the titlepage environment or as last command inside this environment. \documentclass{book} \usepackage[cleardoublepage=plain]{scrextend} \usepackage{fancyhdr} \pagestyle{fancy} \usepackage{blindtext}% ...


2

Here is a solution Edit: more explanation pagestyle is fancy, pages between chapters are set to plain by redefining \cleardoublepage (this last command is used by \part and \chapter) the page after part page is set to plain by redefining \@endpart the page after title page is set to empty by this pagestyle{empty} just after titlepage environment ...


2

You probably need to redefine your titlepage environment. Mine is like this, and the first page after titlepage is empty and the following are numbered correctly. \newenvironment{titlepage} {% \if@openright \cleardoublepage \else \clearpage \fi% \newpage \thispagestyle{empty}% \setcounter{page}\@ne }% {\newpage \thispagestyle{empty} ...


2

Perhaps you can use the "ifdraft" package and use one of these: \ifdraft{draftcase}{finalcase} \ifoptiondraft{option draft is given}{option draft is not given} \ifoptionfinal{option final is given}{option final is not given}


1

the draft option just does \setlength\overfullrule{5pt}} so you can use the test \ifdim\overfullrule>0pt not draft \else draft \fi


2

The following code \documentclass{article} \usepackage{ifthen} \newcommand{\foo}[1]{% \ifthenelse{\equal{#1}{True}}{gagagag}{blablabla}% } \begin{document} \foo{\val} \end{document} yields gagagag when compiled with pdflatex '\def\val{True}\input' file.tex and blablabla when compiled with pdflatex '\def\val{something else}\input' temp.tex ...


5

Maybe better than \newcommand[1]... is usage of toks registers: \newtoks\institution \newtoks\datesattended \newtoks\degree If user says \institution{Ministry of Silly Walks} then you can use this value in your macros as: \the\institution If you need to test, if the value of the "variable" was already set, you can do: \if\relax\the\degree\relax ...


8

There is nothing special about \@variable commands. They are just macros, for storing content rather than performing other operations. As such it's possible to test for being defined, by using \ifdefined, a (e-TeX) primitive. \documentclass[11pt,a4paper]{article} \makeatletter \newcommand{\@institutionname}{Ministry of Silly Walks} ...


3

Since you may want to set a pretty small threshold, it is not efficient to try out combinations like 30*##1<3E-6. Simply enable fpu and use \ifpgfmathfloatcomparison. (The latter seems to be undocumented. And its friend \ifpgfmathcomparison is mentioned once. However you may take a look at pgfmathfloat.code.tex.) columns/B/.style={column type=c,column ...


7

In your last test, when the macro is expanded TeX is doing \ifx``quote''\relax which of course returns true, because \ifx compares the two backquotes. The code \ifx#1\relax can be relied upon only if #1 consists of just one token. You could do \ifx\relax#1; in this case the last test would do \ifx\relax``quote'' and `quote'' would disappear as part of ...


6

Use the max function provided by expl3 in the fp module: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\findLargest}{ om } { \IfNoValueTF{#1} {% separator is a comma, directly use \fp_eval:n { max ( #2 ) } \engbird_compute_max:n { #2 } } {% we need to pass the separator \engbird_find_largest:nn { #1 } { ...


2

I added a *-variant that prints the citation anyway, and it doesn't count as the first (maybe you want it in the introduction or later in the document). \begin{filecontents*}{\jobname.bib} @Manual{vcd, title = "vcd: Visualizing Categorical Data", author = "David Meyer and Achim Zeileis and Kurt Hornik", year = "2015", note = ...


1

on the assumption that \nocite isn't really needed, this should work: \newcommand{\expkg|[1]{\textsf{#1}\ixp{#1}} \newcommand{\pkg}[1]{\textsf{#1}\ixp{#1} \citep{#1}\expkg{#1}} after all, a single \cite will put an entry in the \.aux file that tells bibtex to identify a matching entry in the .bib file and create an equivalent entry in the .bbl file -- ...


3

May be you need this: \def\pkg#1{\textsf{#1}\ixp{#1}~\citex{#1}} \def\citex#1{\expandafter\ifx\csname cit:#1\endcsname\relax \expandafter\gdef\csname cit:#1\endcsname{}% \citep{#1}% \else \nocite{#1}% \fi } The \citex macro tests if the parameter was used before, i.e. if the control sequence \cit:parameter is defined. If not, then ...


0

This is not a direct answer, but perhaps you would find it useful. Here is a package I wrote, but never published to serve a similar but not identical purpose. The purpose of this package is to make it easier to write articles on programming languages. To reference a language such as Java, you write \Java in your input. It would add the citation, but only if ...


1

The expansion of ifthen macros causes problems in the auxiliary files. You either need to \protect them ... \caption[\protect\vlabel{numbersa}]{\vlabel{numbersa}} ... or use an alternative: \documentclass{article} \newcommand{\vlabel}[1]{% \ifnum\pdfstrcmp{#1}{numbersa}=0 Numbers A% \fi } \begin{document} \listoftables% LoF \begin{table} ...


1

The solution by Steven is based on the fact that the parameter is processed. I show another solution here: the parameter is only scanned token by token. The solution is based on the code available at OPmac tricks www page. Only few lines are added in order to implement the actual task here. %% the code from http://petr.olsak.net/opmac-tricks-e.html#readtoks ...


3

Since counters are global quantities in LaTeX, I decided to use them to approach your problem. This doesn't give quite the answer you requested, because it prints the innermost result before it prints the outermost result in the nest. That means, for your first example, that the output is "0 1" rather than "1 0". But I'm thinking that, for what you want ...



Top 50 recent answers are included