# Tag Info

4

\directlua does expansion, so you are doing if U01 == ("U01") that clearly returns false. You have to quote the string: \documentclass{article} \begin{document} \newcommand{\testmacro}{U01} \directlua{ if "\testmacro" == "U01" then tex.print ("testmacro equals U01") elseif "\testmacro" == "U02" then tex.print ("testmacro not equal") else tex.print ...

7

You can use the etoolbox package to create a toggle to be switched on when you call \chapter use the toggle to determine whether a chapter has been created. The trick is that the command that does the check sets the toggle to false Here is how to do that \documentclass[11pt]{report} \usepackage{etoolbox} \newtoggle{chaptercreated} ...

6


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

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

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

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

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

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

3


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

0

I was a beginning this time that I posted, but now I am using \newcommand \name \femalemale {f} \IfStrEq {\femalemale}{f}{female}{male} It solves my question.

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

Top 50 recent answers are included