# Tag Info

12

TL;DR: You're actually looking for \IfFileExists{/Mac/path/macros.tex}% {\input{/Mac/path/macros.tex}} {\input{/linux/path/macros.tex}} The macro \InputIfFileExists{<file>}{<true>}{<false>} takes three arguments: the file to check the existence of, the <true> code to execute before inputting the file in case it is found and ...

7

The \newif command doesn't check whether the conditional is already existing; the assumption is that a programmer using \newif knows what she/he is doing. If you want an interface like \newcommand, load ifthen and use \newboolean; in this case \newboolean{x} would tell you ! LaTeX Error: Command \ifx already defined. Or name \end... ...

6

There has been no change to \InputIfFileExists since 1995/05/25 so unless you have not upgraded for a long time the system upgrade is probably unrelated. However a better, more portable, and more efficient, markup here would be \documentclass{amsart} \input{macros} \begin{document} text \end{document} or better still rename macros.tex to macros.sty and ...

5

biblatex has a host of commands for that. There are (see pp. 199-200 of the biblatex doc) \ifinteger to check if the given argument is a positive integer \ifnumeral to check if the argument is a number given either in the Roman or Arabic system \ifnumerals for ranges of (Roman or Arabic) numerals \ifpages for detection of pages Those commands have a ...

5

The babel language files use \ProvidesFile with some version information argument -- this setup is necessary to use the LaTeX core macro \@ifl@ter to check the file date, if it is applied with the correct extension. It checks the file date, see the definition and the usage in latex.ltx: \def\@ifl@ter#1#2{% \expandafter\@ifl@t@r \csname ...

5

Your code is doomed to failure. The conditional \if tests character code equality of the next two unexpandable tokens it finds after it, performing expansion until unexpandable tokens remain. So \if{\tmpOne}{hello} goodbye \fi sees {, which is unexpandable and then expands \tmpOne; after this expansion the input stream is \if{hello}{hello} goodbye \fi ...

5

You can add another guard within the ln and give a safe value (1 here) it doesn't really matter what non-error value you use as it will not affect the result of the outer guard \documentclass{article} \usepackage{tikz} \begin{document} \def\var{0} \pgfmathparse { \var>1 ? ln(\var>1 ? \var:1) : \var}\pgfmathresult \def\var{1} \pgfmathparse { ...

4

In LaTeX, Version dates can be declared by: \ProvidesClass{<class name>}[YYYY/MM/DD ...] \ProvidesPackage{<package name>}[YYYY/MM/DD ...] \ProvidesFile{<file name>}[YYYY/MM/DD ...] and LaTeX provides: \@ifclasslater \@ifpackagelater \@iffilelater is missing and both commands can only be used in the preamble. Package ltxcmds closes ...

4

If arguments 2 and/or 3 are blank, they are omitted, along with the space that follows. \documentclass{article} \newcommand{\entry}[4]{\framebox(7,7){}\hspace{.75em}\markboth{#1}{#1}\textbf{#1}\ % \ifx\relax#2\relax\else{(#2)}\ \fi% \ifx\relax#3\relax\else\textit{#3}\ \fi% $\bullet$\ {#4}} \begin{document} \entry{Purfling}{pur-fling}{Guitar ...

4

It is not possible to emulate conditionals (\iftrue, \iffalse, \else, \fi) by macros, because TeX's scanning for \else and \fi does not involve macro expansion. The conditional commands can only be assigned to other names (via \let). The starting conditional can be hidden inside macros as long as it is not inside the branch of another conditional. Example ...

3

Here comes some sort of safety-belt with(out eTeX) bloatware: \documentclass{article} \makeatletter %%---------------------------------------------------------------------- %% Check whether argument is empty: %%...................................................................... %% \@CheckWhetherNull{<Argument which is to be checked>}% %% ...

3

the requested syntax seems very odd, but width= and scale= are just variants of scaling with width implying scaling the natural width so you just need the following which avoids duplicating \includegraphics: \documentclass{article} \usepackage{graphicx} \makeatletter \newcommand\zz[1]{#1\ifdim#1pt<1pt \Gin@nat@width\else\textwidth\fi} \makeatother ...

3

It makes very little sense requiring something like width=1.2\textwidth: if the first item is bigger than 1, the image would be scaled to be wider than the text width. And mixing scale and width is rather dubious. However, the customer's always right. ;-) \documentclass{article} \usepackage{graphicx,xparse} \NewDocumentCommand{\mycmd}{o ...

2

Here is a suggestion based on the following assumptions: You want to enumerate agenda items; and Conditionally print a summary of the enumerated agenda items. We address (1) by writing agenda items as \sections. You already do this using \item{...} (which doesn't take a mandatory argument anyway), hence my suggestion. (2) would be equivalent to writing a ...

2

I admit I don't fully understand what you're trying to do here, but as egreg notes, \begin and \item are fragile which is what's causing the problem. It's easy enough to "fix" this particular example \newcommand{\wrapper}[1]{% \test{% \begingroup \let\begin\relax \let\item\relax \let\end\relax \protected@edef\x{% ...

2

Your definition of the teachr environment is incorrect. You're probably after something like this: \usepackage{environ} \NewEnviron{teachr} {\ifthenelse{\boolean{teach}}{\BODY}{}} The above uses the environ package to define teachr and condition on the teach boolean. If it's set to true, \BODY is set, otherwise teachr gobbles its entire contents. One ...

2


2

Something like this? \documentclass{article} \begin{document} \newcount\group \newcount\subj \newcount\nors \group=0 \loop \advance\group by 1 \subj=0 {\loop \advance\subj by 1 \nors=0 {\loop \advance\nors by 1 { group \the\group, subject \the\subj, run \the\nors \par \ifnum\group=2 ...

1

I marked egreg's answer as accepted, because it actually answered the question as written. I ended up solving the problem a slightly different way and am posting this answer in case it benefits anyone else. I ended up using a \newif. \newif\iftestEmptyBool \newcommand{\testEmpty}[1]{\setbox0=\hbox{#1}\ifdim\wd0=0pt \testEmptyBooltrue\else ...

1

I think the easiest way to do this is probably to define a colour newcol, say, which you then set appropriately. This avoids the problems caused by trying to deal with the colour setting while actually testing. Minimising the example a bit: \documentclass{article} \usepackage{tikz} \usepackage{ifthen} \definecolor{newgreen}{RGB}{173,194,0} ...

1

A very rudimentary version since there is no clue provided how the 'versions' are organized. Use a \newif\ifversionA switch and set it to true with \versionAtrue or false with \versionAfalse. \documentclass{article} \newif\ifversionA \versionAtrue \begin{document} Person X \ifversionA -- is so dreamy \else -- is not really lovely \fi ...

1

Testing for the fd-file is useless: It exists anyway, also it contains only font definitions, it is not the font itself. You need to test for a tfm and/or a pfb-font which is specific to the complete version. With pipes enabled you could do something like this (see Search for files first in the texmf trees): \documentclass{article} \pdfmapfile{=mtpro2.map} ...

1

I posted a similar question on academia.se today and was pointed to this question. I posted a hack there which can work for your situation also. Basically make a separate empty file called myclass.dont.upload.to.arxiv then use IfFileExists function in latex to test whether this file is present or not and take action accordingly. When you have to upload the ...

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