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
1 vote
1 answer
39 views

`foreach` does not work together with `ifthenelse` and `mod`

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
  • 616
0 votes
0 answers
67 views

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 ...
RLK's user avatar
  • 21
2 votes
1 answer
48 views

\ifthenelse atomic proposition not behaving as expected when paired with fancy footer

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
0 votes
0 answers
23 views

Suppress 'note' field if empty from custom endnote in Image Credits page

I have an Image Credits page where I cite images using standard citations in a bib file. I use the 'note' field to report licensing information. Sometimes this field is empty and then the word 'note' ...
Paul's user avatar
  • 23
1 vote
0 answers
37 views

rotate table or not, depending on its width

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

How to Color Certain cells in TikZ Pictures

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

Printing toc/lof/lot/others

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

Missing number, treated as zero error when using for loops and conditionals in tikz

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

A sheet of Input-Orders

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
  • 89
0 votes
1 answer
61 views

beamer and \ifstrempty

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
  • 761
1 vote
1 answer
82 views

LaTeX: \equal not recognized within \section command

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
  • 29
0 votes
2 answers
46 views

ifthenelse with mismatched braces [duplicate]

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
  • 414
1 vote
1 answer
71 views

Incomplete ifElse

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
  • 137
0 votes
2 answers
67 views

Two texts with the same width on two different lines, but with different font sizes

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

iftoggle or ifthenelse within a bibtex file, author field not expanded

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

Error with a command whose purpose is to allow a value to adapt over the course of a document

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
  • 515
2 votes
0 answers
52 views

\iffalse not working inside of table

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
  • 531
4 votes
3 answers
149 views

Have something appear in the footer only if section isn't over

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

Add a plural sign depending on the number of items

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

A funny bug with input, newcommand, ifthenelse in a beamer

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
  • 89
3 votes
1 answer
27 views

How can I access \institute content with \ifthenelse in beamer?

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,505
2 votes
1 answer
629 views

How is \iffalse ... \fi handled?

Let's have a look at the example: Some text. \iffalse Nothing to print. \fi Further text. I would expect that this is handled like Some text. Further text. because the system simply removes the ...
principal-ideal-domain's user avatar
0 votes
0 answers
50 views

Remove \thechapter in the Introduction

I'm using classicthesis with scrbook class, and my headings are defined as follows: \renewcommand{\sectionmark}[1]{\markright{\textsc{\MakeTextLowercase{\thesection}} \spacedlowsmallcaps{#1}}} \lehead{...
Guille Carrion's user avatar
0 votes
0 answers
43 views

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 ...
asdlkjsadflkj's user avatar
0 votes
1 answer
40 views

Redefining a command with arguments inside another comand sometimes does not work

I try to generate a \law command that behaves differently depending on the settings. \setlaw changes the behaviour differently. It seems to work for the first two cases. However, when trying to put ...
mrCarnivore's user avatar
  • 1,505
2 votes
1 answer
45 views

Why does \insertauthor lead to an error inside \ifthenelse statement?

Using \insertauthor in \ifthenelse statement throws an error (no error if it is used elsewhere in the document). \inserttitle or \insertdate works fine. Why do I get an error when I use \insertauthor ...
bgn's user avatar
  • 21
0 votes
1 answer
55 views

Switch case environment that provides different kinds of braces for an equation

I'm trying to create a shortcut for equations inside braces. Specifically, I'd like to create a command that works like this: input: \strongbraces{my particular expression} %basically the default ...
mathbaby's user avatar
0 votes
1 answer
87 views

Typical mistake: xspace is always looking forwards, never backwards [closed]

How could we explain the difference between those two outputs, where the second one features } just after \xspace? MWE \documentclass{article} \usepackage{xspace} \usepackage[citestyle=authoryear]{...
Vincent Krebs's user avatar
4 votes
1 answer
218 views

Why 'yellow' isn't good for optional parameter of \fill, when it is the results of an \ifthenelse command?

Can anybody help me? Why are the 1st, 2nd and 5th code good but 3rd and 4th stop with warnings. First code is OK \documentclass{article} \usepackage{ifthen} \usepackage{tikz} \begin{document} \...
1111pataki's user avatar
2 votes
1 answer
69 views

Alignment of if-else notation

I have three if-else condition notations one after the other. I want to align their brackets together but can't do so. \begin{equation*} \begin{rcases} \texttt{Chapter 1} \\ \texttt{Chapter 2}\...
GedankenExperimentalist's user avatar
0 votes
0 answers
25 views

Omit page reference if target is on the same or the facing page

I'm working on a two-side scrbook in which references are made to other sections, figures, etc. If the target is on the very same page, I want to omit a page reference in the text (i.e., if we're on ...
hschmauder's user avatar
0 votes
0 answers
41 views

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 ...
Disatiler's user avatar
3 votes
3 answers
118 views

canonical macro definition for conditional with discrete choices from valid set

what is the canonical way to define a macro (presumably, now xparse is preferred) that acts differently based on one of a set of discrete choices. \mymacro[a]{does one thing, e.g., print this in red} \...
ivo Welch's user avatar
  • 3,768
2 votes
2 answers
218 views

LaTeX3 case inside \equal

I have a LaTeX document where I have defined a switch case command using LaTeX3 syntax. I am using the case inside the \equal condition of an \ifthenelse command. However, I keep getting the wrong ...
Alberto's user avatar
  • 143
2 votes
2 answers
73 views

How to compare an argument to a given string, within a 'newenvironment' definition?

Problem description I am trying to create an environment that produces boxed paragraphs with different styles. So I tried to implement some "if"-"elif"-"else" blocks, ...
Mycroft_47's user avatar
0 votes
1 answer
79 views

Calculating marking points exam class

I want to calculate marking points for an exam by multiplying a percentage with the total number of points (e.g., 0.5 * \numpoints{}) to make a grading table. Problem is that before I run the ...
bjpean's user avatar
  • 1
1 vote
2 answers
88 views

Using boolean functions \ifthenelse changes citation numbers with complex bibliography setup

Finally my example with different options of bibliography works fine thanks to moewe. To the below example I needed to add boolean function: \usepackage{ifthen} \newboolean{print_or_not} \setboolean{...
L. Flis's user avatar
  • 53
0 votes
0 answers
62 views

\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.
Steven Schneiders's user avatar
4 votes
3 answers
281 views

Division by zero and precision in math calculations

I have this table who is like almost to all my wishes: This is my code: \documentclass[border=5pt]{standalone} \usepackage{tikz,siunitx,calc} \begin{document} \sisetup{round-mode = places, round-...
Raffaele Santoro's user avatar
2 votes
2 answers
82 views

Creating newcommand for a tens frame grid using tikz

I'm trying to create tens frames to model addition of numbers. I'd love it if \tensframe{#1}{#2} would show #1 green circles starting on the left and growing up, then #2 blue circles continuing from ...
Wendy Taylor's user avatar
0 votes
1 answer
68 views

Exit \ newcommand before exit [closed]

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) { ...
Arek's user avatar
  • 29
1 vote
1 answer
85 views

Code optimization: Boolean token equivalent to \ifdefempty, which can combine with \OR or \AND

I'm a new LaTeX user looking for some guidance. I wish to optimize the following code, since lines 3 and 5 are unnecessarily repeated, because I am using \ifdefempty{}{}{}, instead of some Boolean ...
BhaveshDiwan's user avatar
1 vote
0 answers
21 views

I want Section 1 and chapter one the same page. otherwise the section on the new page

\usepackage{ifthen} \ifthenelse{\value{section}=1\OR \value{section}=0} {\renewcommand*{\thesection}{\arabic{section}} \let\bkdsection\section \renewcommand*\section{\bkdsection}} {\...
Trần Văn Quang's user avatar
1 vote
1 answer
165 views

Omitting a dinkus / separator if it would be the first or last element on the page

I am working on a book of demotivational aphorisms. Since the aphorisms are brief I'm wrapping them in samepage and I allow more than one per page, if they fit. This kind of layout benefits from some ...
Liisi's user avatar
  • 137
0 votes
1 answer
146 views

Get value of Biblatex's printfield{}

I would like to compare the value of a \printfield command in \ifthenelse It seems printfield does not return the value so ifthenelse can't check it. How can I access the value in a way that ...
Colin P's user avatar
  • 167
1 vote
2 answers
71 views

How define a command with argument to specify which list to return?

I want to define a command that returns one or another list, as a list enclosed in braces, that, in my real document and not this MWE, I can use as an argument to something else (namely, the list over ...
murray's user avatar
  • 7,964
0 votes
1 answer
100 views

Disable a package/classoption when the draft mode is on

I have a custom .cls file which passes the parameters of the \documentclass to a4paper. In this .cls file, I have (from the top), \NeedsTeXFormat{LaTeX2e}[1996/12/01] \ProvidesClass{Thesis} ...
Tom's user avatar
  • 123
0 votes
2 answers
107 views

How to check that something starts with * (or how to build your own exercise sheet from a moodle database)

I would like to check if something starts with an asterisk (*) My attempt: \def\testast#1{\ifx*#1\relax YES\else NO\fi} But the output of \testast{*Word} is WordYES while I would expect just YES The ...
user126154's user avatar
1 vote
3 answers
253 views

Custom new command in math mode with two alternative outputs depending on input arguments

I have written some custom commands to use inside mathmode. The command basically corrects the style of the left side sub and superscript. It decides which script is the longest and right-justify the ...
Jared Lo's user avatar
  • 652
4 votes
2 answers
187 views

How ifthen \equal could compare \relax to another \relax-like command?

I was implementing an ad hoc list data structure inside LaTeX, where \aaa expands value for aaa, \bbb exapnds value for bbb and to show that \bbb is next to \aaa on the list, \NEXTaaa expand to bbb, ...
Miguel V. S. Frasson's user avatar

1
2 3 4 5