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

The command \ifthenelse is invoked within of the package ifthen: https://www.ctan.org/pkg/ifthen. In fact the package's basic command is \ifthenelse, which can use a wide array of tests. Also provided is a simple loop command \whiledo.

218 questions
5
votes
2 answers

Check if number is in list

My goal is to have different headers and sortings depending on a list of numbers. I have multiple projects ordered by project number (desc). Now I want to highlight some projects, so that the highlights come first and then the other projects.…
4
votes
2 answers

plain IF structure with one def-ed token and one literal

In some hand-me-down tex i inherited, a control sequence is used as a variable, for instance: \def\accessflavor{ats} it is used to generate postfixes on included tex files (called, i.e., image01_ats) and the like. I want to use it in a conditional…
bukwyrm
  • 267
4
votes
1 answer

Problem with \ifthenelse

\documentclass{article} \usepackage{ifthen} \newcounter{theyear} \setcounter{theyear}{\number\year} \newcommand{\shorttoday} { \ifthenelse{\number\month<5}{May, }{\ifthenelse{\number\month <8}{August, } {\addtocounter{theyear}{1} January,…
2
votes
2 answers

Nested if-then-else statements

I try to use nested if-then-else conditions: \documentclass[10pt]{article} \usepackage{ifthen} \newcommand{\printTrueOrFalseA}[1]{% …
anja
  • 21
2
votes
1 answer

Ifthen and tabularx environment

I want to have the beginning and end of a tabularx table appear only in some cases, but this does not seem to be possible. I get a "Runaway argument error". Why is wrong, or is this kind of construction impossible? Here is a minimal…
1
vote
0 answers

How can I switch quickly betwen two style files?

I would like to switch between two styles in a simpler way, I have two sty files (say a.sty and b.sty) and a different bibstyles for each file (say a.bst and b.bst). In order to switch between two formats I rewrite \bibliographystyle{} and…
SagarM
  • 143
1
vote
1 answer

I am using \if condition in a custom command in my LaTeX document. can i know how to do the if statement in the uploaded image

\documentclass[a4paper,11pt]{article} \usepackage{siunitx} \usepackage{algorithm} \usepackage{algpseudocode}…
0
votes
0 answers

Precedence of \and and \or

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 expression like \ifthenelse{\boolean{boolval1} \and…
RLK
  • 21
0
votes
0 answers

Is there a way to change multiple lines depending on a condition?

I'm working on my resume, and I have two versions -- one more tailored towards the Biology/premed side of my experience, and another focused more on my computational side. Right now, whenever I'm updating my resume, I have to comment/uncomment each…
0
votes
0 answers

Error Missing Number, treated as zero after two If

I have trouble with \tikzset. When I create a function (here foo), the parameter \lfvert is not recognize on the second if statement. (The node didn't print it anymore) And that give me the following error Missing number, treated as zero. Despite…
0
votes
0 answers

\newcommand for \ifdefined

Is there a possibility to design a \newcommand for the if-structure? I want to shorten the \ifdefined\todo text \fi into something where I simply need to write \todo text without the \fi.
0
votes
1 answer

Exit \ newcommand before exit

I need to prevent commands from reprocessing a parameter. Is there the way to exit command before end if condition is met just like return in JavaScript functions: function calculateSomething(param) { if (!param) { return // <---- leave the…
Arek
  • 29
0
votes
1 answer

Use of an \if statement inside a tikz environment

In order to illustrate a large chapter number on the beginning of each chapter, I created a tikz environment and added it to the CLS file like this: \begin{tikzpicture} ........ \node[anchor=north west, inner sep=0pt, ] at…
0
votes
1 answer

Using a command with ifthenelse for setting a section title

I want to set the title of a section with a command which includes an \ifthenelse condition: \documentclass{article} \usepackage{ifthen} \newcommand{\region}{Germany} \newcommand{\getValue}{ \ifthenelse{\equal{\region}{Germany}}{ …
Jonathan
  • 113
0
votes
0 answers

Generating multiple versions of a document using a command inside \ifthenelse

I'd like to be able to generate different versions of a document using some kind of print command inside an \ifthenelse statement. Here's an example of what I would like to do. I'd like to do it this way because my document is quite long and has…
Lisa
  • 123
1
2