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
227 views

Conditional tests on string variables in tikzmath library

Is it possible to test for strings in the tikzmath library? (E.g. if <variable>=<string expression> then foo) I tried a naive test and it returned this error: Package PGF Math Error: ...
2
votes
4answers
200 views

Programming a step function- part2

Based on a macro given by egreg in this question: Programming a step function I obtain a program which tests in which interval is a number \alpha, between the numbers bone, btwo, bthree, bfour. I use ...
2
votes
1answer
330 views

Conditional page break to start a new section

I am trying to have a conditional page break for a section if there is not enough space in the bottom. To be clear, when an new section starts I want to check if there is enough space (25% of the text ...
2
votes
2answers
664 views

Set comment toggle to false, error: Undefined control sequence

I want to toggle comments of and on. Off works, but when I set toggle to true, then I get an error: ./main.tex:36: Undefined control sequence. \endtcolorbox ->\unskip \tcb@after@box ...
1
vote
3answers
278 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
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
1answer
992 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
71 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
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
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
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
271 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 ...
1
vote
1answer
42 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
49 views

Tables: Cell Color based on content / conditional cell coloring

I want a table to have red or green cell color, depending on the content: If the content is "a", make it green, if it is "b", make it red. BUT if the content is something else (e.g. in the column ...
1
vote
1answer
278 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
2answers
109 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
595 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
2answers
872 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
40 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
1answer
82 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 ...
0
votes
3answers
1k views

switch-case condition [duplicate]

There are only two clause in \ifthenelse—<then clause> and <clause>. If more than two test conditions are needed, the \ifthenelse has to be nested. This will make code awful and be hard to ...
0
votes
1answer
45 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
2answers
546 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
2answers
88 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
1answer
60 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
86 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 ...
0
votes
1answer
49 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
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
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
640 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}{...