Skip to main content

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 \( \).

Filter by
Sorted by
Tagged with
5 votes
5 answers
234 views

I have a list of numbers from 1 to 12. I want to print the numbers 3,6,9 and 12 in purple, the others in blue. With my code: \documentclass{standalone} \usepackage{tikz,ifthen} \begin{document} \...
Raffaele Santoro's user avatar
2 votes
2 answers
109 views

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 ...
underflow's user avatar
  • 1,129
3 votes
2 answers
134 views

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} \...
underflow's user avatar
  • 1,129
0 votes
2 answers
59 views

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 ...
user1771398's user avatar
3 votes
2 answers
117 views

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....
Jun's user avatar
  • 93
5 votes
2 answers
336 views

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 ...
Mikhail Stolpovsky's user avatar
2 votes
2 answers
191 views

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 ...
H. Pecoraro 's user avatar
2 votes
1 answer
73 views

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 ...
antonio de la rosa's user avatar
0 votes
1 answer
74 views

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} \...
Paco Robledo's user avatar
2 votes
2 answers
88 views

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 ...
user1451632's user avatar
3 votes
1 answer
95 views

Consider the following MWE: \documentclass{article} \usepackage{fullpage} \newcounter{question} \renewcommand{\thequestion}{\Roman{question}} % see https://tex.stackexchange.com/a/729773/10898 \...
azetina's user avatar
  • 30.9k
2 votes
3 answers
242 views

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 ...
Garth Fleming's user avatar
3 votes
3 answers
263 views

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 ...
Benny Wang's user avatar
0 votes
1 answer
85 views

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 ...
Chris Peh's user avatar
  • 321
3 votes
3 answers
216 views

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 ...
Ben Grossmann's user avatar
0 votes
0 answers
102 views

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 ...
Chris Peh's user avatar
  • 321
1 vote
1 answer
78 views

I made a tcolorbox based environment that I want to toggle on and off depending upon whether I want to show the solutions or not. The following code works fine when \boxtoggle is set to 1, but not ...
R Walser's user avatar
  • 321
1 vote
2 answers
242 views

Note [cfr]: the code below does NOT work. Please follow the link for amended code which does. I do not know how to edit this question without changing its meaning and its author has not updated it in ...
Vincent's user avatar
  • 6,225
2 votes
1 answer
73 views

I'm trying to build a repeating graph that starts at t-1 and progresses to t+1 but I can't figure out how to print the time series correctly. I have three identical diagrams cascaded where the left ...
JKomp's user avatar
  • 144
2 votes
2 answers
250 views

I want to check the page count of the entire document to implement different commands using an if-then-else statement. I've looked all over SE, but I haven't found a solution that works for me; if I ...
Ernesto's user avatar
  • 407
2 votes
1 answer
190 views

I'm using the resume.cls made by Trey Hunner (see here for Github link if interested). The below is a minimally-reproducible example. The resume.cls only allows me to add in a single job title and ...
C.Robin's user avatar
  • 121
1 vote
0 answers
55 views

I want to use \ifthenelse while defining symbols with \newcommand. This works all fine, until I try to use those symbols (here \densCanv) in my glossary as a name: \documentclass[a4paper,10pt]{article}...
Make42's user avatar
  • 1,832
0 votes
1 answer
105 views

\documentclass{article} \usepackage{ifthen} \usepackage{currfile} \newcommand{\textforpicture}{ \ifthenelse{John}{This is text 1 and the name of this file is \currfilebase}{nothing} \ifthenelse{Jack}{...
mario1000's user avatar
  • 542
2 votes
2 answers
191 views

Very often I want to refer to a certain claim I mentioned earlier in the document: "As I said earlier, blah." Since I often rearrange material, I need to ensure that "blah" indeed ...
Jabot's user avatar
  • 343
3 votes
2 answers
505 views

I want to make a conditional statement that draws one tikz picture for specific values of \t and another for different \t values. Here is a M(non)WE: \documentclass{article} \usepackage{tikz,ifthen} \...
Jasper's user avatar
  • 10.9k
1 vote
1 answer
120 views

I am trying to write a solutions environment sol which I can use to write solutions within assignments. There are two reasons for the environment, Solutions may be different colour. Solutions can be ...
scribe's user avatar
  • 345
1 vote
0 answers
55 views

I am trying to write a form in Latex where I'm asking a question an if the answer is no I whant to ask another question. I'm a real beginner in Latex and I need a little help how to start it. It ...
Andrea K's user avatar
3 votes
3 answers
487 views

I'm struggling with the correct use of conditional expressions with ifthenelse at the moment. I would like to define a command (or similar) that represents a certain conditional expression in order to ...
Simon's user avatar
  • 145
1 vote
1 answer
69 views

\documentclass{article} \usepackage{caption} \usepackage{booktabs} \usepackage{csvsimple} \csvstyle{mystyle}{ tabular=|c|c|c|, table head=\hline Gruppe & Buchstabe & Zahl \\ \hline, ...
Roman's user avatar
  • 21
1 vote
0 answers
15 views

I'm trying to define a command which raises an issue about spaces. Basically, I want to have a single command for these two : \documentclass{article} \newcommand{\Cinf}{$C^\infty$ } \newcommand{\...
Loulou's user avatar
  • 281
1 vote
1 answer
117 views

In the minimal example below, the commented out line does not work. Other lines work correctly. I can't understand what the reason is. Here is a similar question, but my variable \im takes integer ...
kabenyuk's user avatar
  • 12.4k
0 votes
0 answers
182 views

I am using the ifthen package. I see some comments on the web that there is a more recent alternative, so maybe the answer to this is, I should switch. But in any event . . . So if I have an ...
RLK's user avatar
  • 21
2 votes
1 answer
90 views

I understand that the title of the thread is a bit cryptic, but I admit that I don't have much of a clue about the reason for which this (apparently simple) conditional (sometimes) fails in working as ...
il mietitore's user avatar
1 vote
0 answers
59 views

I build a Tex file in C# and then compile to PDF. How would I rotate a table sideways if it is to wide for portrait? So the actual, displayed width is only known AFTER the table is generated in C#.. I'...
Erik's user avatar
  • 167
1 vote
1 answer
125 views

I'm interested on coloring certain cells of a TikZ picture. It is the following: I did it by using the grid and creating the numbers. I present the code I create above: \begin{tikzpicture}[scale = 0....
MathHack's user avatar
1 vote
0 answers
47 views

How can I print toc only if isn't empty? \documentclass{article} \begin{document} %if there is a section, toc will be printed, else it wont be \tableofcontents %\section%in this case it wont be ...
Leonidas's user avatar
1 vote
1 answer
99 views

I would be nice to be able to have a code that, by modifying certian parameters like height and width and cells to be colored red or green, generates a table for me. The code I have is already a ...
Ben Thomas's user avatar
0 votes
1 answer
69 views

I have a sheet of input orders like: \input{something} \input{another thing} \input{some other thing} ... I want to make a command like \myinput{} so that if I use \myinput{24} then that will input ...
Ngiap's user avatar
  • 99
0 votes
1 answer
132 views

EDIT. Consider the following code. I wish to avoid empty beamercolorbox, if the required item to insert therein is empty. Consider the case of a section without a subsection, then the subsection ...
mario's user avatar
  • 825
1 vote
1 answer
142 views

I have the following code, where I want to steer the language of some titles and some texts using a "\newcommand". The following minimal example uses the new command "kLanguage", ...
iGeeks's user avatar
  • 121
0 votes
2 answers
104 views

I am writing some lecture notes, and I would like to have automatically generated two versions. One version includes everything (examples, additional explanations, etc.), and another one with only the ...
D.F.F's user avatar
  • 434
1 vote
1 answer
154 views

Overleaf gives me an error saying that there's an incomplete if-else. I don't have any if-else in the document. I'm not sure why there's an error. If I comment out the second \item the compiler is ...
Pss's user avatar
  • 149
0 votes
2 answers
254 views

I want to create a new command for a template cover, and I think a specific type of formatting would look great, but I'm having trouble implementing it. Essentially, what I want to do is have a title ...
Jimeens's user avatar
  • 617
0 votes
0 answers
89 views

I am trying to put a conditional statement within a bib file, namely in the author field. I tried with both the ifthenelse and the iftoggle commands, but to no avail. The condition is respected, but ...
ferdymercury's user avatar
1 vote
2 answers
92 views

I am trying to write a command that will do the following, in order: Measure the width of an input word. Compare this value to an existing value. If the input word's width is greater, then take on ...
Noah J's user avatar
  • 525
2 votes
0 answers
172 views

The following code is supposed to generate a table with a single row and two columns. It does however not compile. The error messages contains Incomplete \iffalse and A forbidden control sequence ...
M. Winter's user avatar
  • 551
5 votes
3 answers
186 views

I'm writing a gamebook. My text is divided into a lot of little paragraphs, with length varying from a couple of lines to a page and a half. Readers/players will start from paragraph 1 and then move ...
il mietitore's user avatar
1 vote
1 answer
107 views

I'd like to add a plural sign (say a 's') when needed. My current use case is for pluralizing a noun based on the number of pages in a document but I could also count oranges and bananas down the road....
green diod's user avatar
2 votes
1 answer
175 views

First I write a tex named thequest like: \begin{quest} Just a problem. \end{quest} Then in the main tex, I write \newtheorem{quest}{Question} \newcommand{\Fakeframe}[1]{\ifthenelse{\equal{#1}{}}{}{ ...
Ngiap's user avatar
  • 99
3 votes
1 answer
73 views

I try to check if \institute is empty in a beamer document. This fails. I found the solution for \author already here: Why does \insertauthor lead to an error inside \ifthenelse statement? You can ...
mrCarnivore's user avatar
  • 1,577

1
2 3 4 5