Tag Info

Hot answers tagged

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


8

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


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


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


5

The \jobname primitive is a TeX string, so all characters have category code 12 (other) not 11 (letter) (with the exception of any spaces, which are category code 10 (space)). Slightly confusingly, xstring is carrying out a token-based comparison here not a string one! Assuming e-TeX is available you can fix your code easily \documentclass{article} ...


3

You need to perform a string comparison with the expansion of \@currenvir against itemize. \ifthenelse with the \equal operator does this, but you're short a magic \makeatletter...\makeatother wrapper (see What do \makeatletter and \makeatother do?). Consider the post Why is the ifthen package obsolete?, I've used the e-TeX \pdfstrcmp to perform a string ...


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


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


3

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


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


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}


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

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

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


2

since you want only a word or so omitted, i think an ordinary command is better than an environment. here's one possibility. \documentclass{article} \newif\ifmycmd \newcommand{\FlagText}[1]{% \ifhmode\unskip\fi \ifmycmd \else \space #1\fi } \begin{document} Here is some text \FlagText{with some words} to be ignored. \FlagText{Start} a new ...


2

You shouldn't use @ in command names, when using ConTeXt; but you should be aware of the fact that ConTeXt uses Unicode math, so the standard math code of the hyphen cannot be accessed to with \mathcode. \begingroup \catcode`\"=12 \catcode`\`=12 % to be on the safe side \gdef\newmcodes{\mathcode`\'39\mathcode`\*42\mathcode`\."613A ...


2

I just realized there is another easy solution. The xstring package has starred versions of its comparison commands that do not take category codes into account. All that is necessary to make the file work is to replace \IfStrEq by \IfStrEq*.


2

The definition text of \insertauthor is not empty, which is quite obvious, because the macro is meant to do something with data that should already have been given. From beamerbasetitle.sty, line 149 and following: % The \author command % % \def\author{\@dblarg\beamer@author} \long\def\beamer@author[#1]#2{% ...


1

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


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


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


1

There are a couple of errors in your code. First: you define \sidenote with an optional argument, but do nothing with it. Second: you don't understand clearly what the optional argument to \marginnnote does. What you have to do is to locally enable \reversemarginpar, not to use the optional argument to \marginnote. Here's a working version. ...



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