Questions tagged [ifthenelse]
\ifthenelse{⟨test⟩}{⟨then clause⟩}{⟨else clause⟩} evaluates ⟨test⟩ as a boolean function, and then executes either ⟨then clause⟩ or ⟨else clause⟩. ⟨test⟩ is a boolean expression using the infix connectives, \and, \or, the unary \not and parentheses \( \).
246 questions
2 votes
2 answers
104 views
floating point arithmetic and boolean operations with \ifthenelse
This is a follow up to my previous post about arithmetic operations and tikz I would like to performance floating point arithmetic & boolean operations in conjunction with \ifthenelse. Here is a ...
3 votes
2 answers
129 views
arithmetic operations with \ifthenelse
Is there a way to add arithmetic operations to \ifthenelse statements? Here is a minimal (non)example: \documentclass{amsart} \usepackage{tikz, ifthen} \begin{document} \begin{tikzpicture} \...
0 votes
2 answers
54 views
Can we mix \newif's \ifname as in \ifgreen with \OR or \AND?
I created \ifCond1 and \ifCond2 with \newif. If I want to test one condition, I use \ifCond1 Condition 1 OK \else Condition 2 KO \fi. My question : is there a way to use \ifCond1 and \ifCond2 glued ...
3 votes
2 answers
116 views
\pgfmathifthenelse gives error
I write exam questions in Latex. I defined parameters and use \pgfmathsetmacro to do the calculation and print the result. This makes it easy to just change the values to generate a different question....
5 votes
2 answers
333 views
Line to be filled by students
I am preparing materials for my students, and I would like to leave some blanks for them to fill in. For this, I want to define a new command — let’s call it \answerline — to be used like this: Dog ...
2 votes
2 answers
190 views
Difficulty writing an ifthenelse style command
Edit: The previous edit removed the extra line in my command definition, but it turns out that this was the actual problem and not that there were mismatches in argument types being passed between ...
2 votes
1 answer
71 views
tcolorbox with and without lower part
My problem is whether or not to show the lower part of a tcolorbox based on a conditional statement that takes a given argument. I'm wondering: Why doesn't the conditional statement work? I've checked ...
0 votes
1 answer
73 views
Position of nodes with the "ifthen" package
I am not sure that the result of this code is the most appropriate for the nodes of points P and Q. What is the mistake made? \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \...
2 votes
2 answers
88 views
generate random lines in a table
I'd like to generate a table with some random content. Ideally, I would have lines like a & b & c where I produce a; and sometimes b is a random number and c is blank; and sometimes b is blank ...
3 votes
1 answer
93 views
Change label based input value
Consider the following MWE: \documentclass{article} \usepackage{fullpage} \newcounter{question} \renewcommand{\thequestion}{\Roman{question}} % see https://tex.stackexchange.com/a/729773/10898 \...
2 votes
3 answers
241 views
Condition IF in Tikz
I would like to draw a Riemann sums plot where the bars are graphed based on the heights of each pair of consecutive intervals. The issue will be with the ifthenelse statement as I do not think the ...
3 votes
3 answers
261 views
Conditionally making environment content disappear
I am working on project from which I want to produce both an answer key and a solutions manual to a long list of questions (I am also producing the problem sheet from this project as well). The ...
0 votes
1 answer
84 views
Compare imported data from CSV with ifthenelse
I'm trying to make a comparison in Latex with data imported from a CSV file. Unfortunately, the comparison doesn't work (or gives wrong result) when variable is assigned a value from CSV file even ...
3 votes
3 answers
216 views
Weirdness with `\ifnum`: `\ifnum\curyear=2024` gives an error, but `\ifnum2024=\curyear` works as expected
After an embarrassing amount of attempted research and trial and error, I've landed on the following code that works as expected. If the current year is 2024, it says "They match!". If it's ...
0 votes
0 answers
102 views
Extracting data from CSV - known cells
I have an Excel file which is created when the user inputs for a quote creation. E.g. in cell "D3" you find the company name, in cell "D11" the expiry date of the quote. Table ...