# Tag Info

7

The LaTeX core defines \@ifclassloaded{classname}{true branch}{false branch} which is basically the same as \@ifpackageloaded for checking whether a certain package is loaded. The class name has to be specified without the usual .cls extension. Since @ occurs in the macro name, \makeatletter...\makeatother is needed in the document preamble, if the check ...

4

\RequirePackage{longtable} \makeatletter \@ifpackagelater{longtable}{2013/10/28} {\PackageWarning{mypkg}{Longtable newer or = to 2013/10/28}} {\PackageWarning{mypkg}{Longtable is older than 2013/10/28}} \@ifpackagelater{longtable}{2014/10/28} {\PackageWarning{mypkg}{Longtable newer or = to 2014/10/28}} {\PackageWarning{mypkg}{Longtable is older ...

4

See also How to use \ref command in the test block of \ifnum? \documentclass{article} \usepackage{lipsum} \usepackage{refcount}% must go before ]astpage \usepackage{lastpage} \begin{document} \expandafter\ifnum\getpagerefnumber{LastPage}>1\relax \pageref{LastPage} pages \else \pageref{LastPage} page \fi \lipsum[1-2] \end{document}

4

With zref package \documentclass{article} \usepackage{lipsum} \usepackage[totpages,user]{zref} \newcommand{\totpages}{\ifnum\ztotpages=1 1 page \else \ztotpages\ pages \fi} \begin{document} \totpages \lipsum[1-2] \end{document}

4

You can't use conditionals inside the options in that way. However you can exploit the fact that \geometry can appear as many times as you want. \newif\ifscreen \screentrue % comment out for printable version \geometry{ headsep=\baselineskip, textwidth=42\baselineskip, textheight=60\baselineskip, heightrounded, vmarginratio=2:3, onecolumn, } ...

3

You can use \ifmmode to check for math mode: \documentclass{article} \usepackage{relsize} \protected\def\a{% \ifmmode% \mathsmaller{\forall} \else% $\forall$ \fi} \begin{document} in text: \a and in math: $\a$ \end{document} See \ifmmode doesn't seem to work correctly inside an array environment for the reason why to put \protected. ...

3


3

This is a slightly more "readable" version of Audrey's approach above \AtDataInput{% \csnumgdef{cbx@instcount@curr@\thefield{entrykey}}{0}} \AtEveryCitekey{% \csnumgdef{cbx@instcount@last@\thefield{entrykey}}{% \csuse{cbx@instcount@curr@\thefield{entrykey}}}% \csnumgdef{cbx@instcount@curr@\thefield{entrykey}}{\value{instcount}}} ...

2

\IfNoValue(TF) is used to test the presence or absence of an o argument. It has nothing to do with checking the emptiness of a token list variable, for which you have to use \tl_if_blank:V(TF). The notation (TF) means you can use TF, T or F (or nothing at all, in some cases, not this one). Note that \tl_if_blank:nTF { \l_tmpa_tl } would always return false, ...

2

Your \end{mynote} is not seen as part of the input stream, as it's hidden within \end{note}. You can use a different technique and capture the entire note environment contents before passing it to a "clean" (or more visible) mynote environment: \documentclass{article} \usepackage{version,xcolor,environ} %\includeversion{mynote} % Like this it works. ...

1

This is a common problem, stemming from the fact that you can't have verbatim content as part of a macro argument. In your case, the verbatim content is a listing, and the macro is \ifbool{<bool>}{<true>}{<false>}. However, etoolbox's \newbool{<bool>} creates a primitive TeX \if<bool>, which you can use to condition. So, ...

1

The following is not thoroughly tested, but should suffice with some tweaking. The idea is to update \newchap to include some code from needspace. This allows you to force a new page based on the amount of space available on the page, and condition accordingly between issuing \thispagestyle{plain} and \thispagestyle{fancy}: \documentclass{article} ...

1

You can also use kvoptions: \ProvidesPackage{mypackage} \RequirePackage{kvoptions} \DeclareBoolOption[true]{fullpage} % automatically creates \ifmypackage@fullpage \DeclareComplementaryOption{nofullpage}{fullpage} % automatically inverses the former \ProcessKeyvalOptions*{} \ifmypackage@fullpage \RequirePackage{fullpage} \fi (based on egreg's ...

1

You can do like this \documentclass{article} \usepackage{lipsum} \makeatletter \AtEndDocument{% \label{LastPage}% \protected@write\@auxout{}% {\string\gdef\string\mtpages{page% \ifx\@begindvi\@empty s\fi}} }\makeatother \begin{document} \pageref{LastPage} \mtpages{} \lipsum[1-2] \end{document}

1

You're taking the wrong approach; you can certainly have a user level command \jkoclass that prints something, but if what it prints is variable data, this data should be allocated its own variable. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn % allocate a (global) variable \tl_new:N \g_macmadness_jko_class_tl % initialize the value ...

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