Questions tagged [conditionals]

{conditionals} is about macros like \if and \ifx that may execute other macros depending on whether certain conditions are true or not. Popular packages are {etoolbox} and {ifthen}.

Filter by
Sorted by
Tagged with
2
votes
3answers
2k views

\pagestyle{plain} between chapters without page number after titlepage?

I've found numerous posts about removing the header/footer on the blank pages between chapters, and they work fine with one big exception... I need a \pagestyle{plain} (i.e. single centered pg#) at ...
2
votes
2answers
93 views

How to determine if a macro is used inside the argument of a sectioning command?

In order to further automatize a macro I have written, I would like to know if there is a possibility to determine if this macro is used inside the argument of a sectioning command or inside the text. ...
1
vote
1answer
71 views

refined equation numbering using other chapter title

I would like to use book class and number equation in that way: The equation have to carry just number of equation without chapter number. I get this using \renewcommand{\theequation}{\...
1
vote
2answers
99 views

Use of graphicspath in class

I am using my own class MyReportClass to write a report. I have taken inspiration from this answer to redefine the \includegraphics command inside the class in order to use the example-image-a in case ...
1
vote
3answers
579 views

Comparing strings with etoolbox

I'm having an hard time understanding how to use the various options etoolbox has for comparing strings. Let's consider this MWE: \documentclass[11pt, a4paper]{article} \usepackage{etoolbox} \...
1
vote
3answers
264 views

How to properly use \DeclareOption within a macro

Using \ifthenelse statements I've defined a macro that prints it's value as long as it is different from the value of the previous time it was used. \RequirePackage{xifthen} \def\storedval{} % create ...
1
vote
1answer
991 views

How to configure fancyhdr depending on the document class [duplicate]

Possible Duplicate: How to configure theorems depending on the document class? I would like to have if the book class is loaded but if the article class is loaded. Can I do this with some sort of ...
1
vote
1answer
39 views

Is there a way to display a specific command and hide the rest

I would like to use the same Latex source file for both my document and the accompanying slides. When creating a document it's easy to hide the slide sections by doing this: \newcommand{\slide}[1]{} ...
1
vote
1answer
41 views

Reset stored values at pagebreaks and environment boundaries

Based on this question, I have created a simple macro that prints and stores its argument, and if it is issued again with the identical argument it prints nothing: % !TEX TS-program = xelatexmk \...
1
vote
1answer
56 views

Output depending on crossreferences

I want to write a specification. It has a section listing all features. Another section lists tests. Each test must reference the feature it tests. Now by TeX-magic, I want untested features be ...
1
vote
2answers
834 views

Language detection and condition

My problem is quite simple. I use the babel package and depending on the language I want to display something with respect to the active language. Therefore I use the package xstring. My code is the ...
1
vote
1answer
98 views

Define symbols differently in text mode versus math mode

I'd like to define \a to be the $\forall$ symbol, but I'd like it be the regular $\forall$ in text-mode and \mathsmaller{\forall} in math mode. Is there any easy way to do this? I'm guessing it ...
1
vote
1answer
80 views

XParse doesn't recognize some of my variables

Based on the comments from my last question have I tried to create a new command using \NewDocumentCommand. However, it wont recognize some of the optional arguments - they just get printed as is. Any ...
1
vote
1answer
67 views

exam class: define new environment which depends on \printanswers

I am having trouble defining a new environment which depends on the \printanswers option of the exam class. \documentclass{exam} \usepackage{framed} \printanswers %\noprintanswers \newenvironment{...
1
vote
1answer
275 views

Environment variable \def if defined else \def default [closed]

Bash example # echo ${FOO:-bar} bar # FOO=haz; echo ${FOO:-bar} haz LaTeX attempt: Repo: https://github.com/AlecTaylor/latex-env-testcase Command (defined in preamble) % Edited from: https://tex....
1
vote
1answer
34 views

XeLaTeX + \ifthenelse:

I use XelaTeX to produce my CV. Currently, I want to update it and have both Slovak and English CV within one document. I want to have all strings of one language grouped in the preamble, same for ...
1
vote
2answers
269 views

moderncv: How to extract the style information and use it in if-statements

I use moderncv for my CV and changed the header for the classic and the casual style (but not the other three styles), following the advice from this post: Moderncv adding date of birth to personal ...
0
votes
0answers
40 views

conditional if / else [duplicate]

I want in following examaple change the day of week according the inputted day. When I use dia in the document work, but when I use inside newcommand doesnt (look the example) \documentclass{article} ...
0
votes
1answer
42 views

How to change the way a counter is presented based on its value?

I need an environment where the way the counter of the environment is presented changes according with the value of the counter. If the counter is less then 10 it must be succeeded by the ordinal mark ...
0
votes
1answer
48 views

What is the correct method for conditional printing of variables?

I hope I've used the right terms for my question. I'm working on a template and it has variables which need to be setup by the user. Not all users have the same amount of variables. Users are ...
0
votes
1answer
605 views

condition if/else

In the following example I want write Tuesday if the variable dia is Monday. The following example write rest not matter the string of variable dia. \documentclass{article} \def\dia#1{\if{#1=monday}{...
0
votes
3answers
119 views

If condition without any package?

I create a table by rows like this: \row{1}{Sunday,Su,05.09.2015}{N}{08:00,17:00,12:00,13:00}{8.0,1}{Airplane Hangar} How can I prove, if the first parameter is 0 or 1, an if it's 1 then set a ...
0
votes
2answers
85 views

Chess notation: Switch between color and notation style

Consider the following two examples: Example A \documentclass{article} \usepackage{xskak} \begin{document} \usetextfig \textsymfigsymbol{R}a1 versus \usesymfig \textsymfigsymbol{R}a1 \end{...
0
votes
2answers
538 views

If condition controlled with a loop variable

I want to print some images according to a variable being changed in a loop: if variable group is 1, then the image should not be printed. But if the value of group is 2, then the image should be ...
0
votes
1answer
59 views

Is there a way to have different behavior for even pages and odd pages

I would like to modify the below template so that it prints out 1 problem per sheet. Example: Problem 1 on pages 1-3, problem 2 on 5-6 and nothing on page 4. Another Example: Problem 1 on Pages 1-2, ...
0
votes
1answer
84 views

Chess notation: figure or symbol

This is somewhat a follow-up question to xskak: Switching between notation styles. I would like to create a command for a pawn move that either gives the name of the file in which the pawn is placed ...