Questions tagged [ifthenelse]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
32 views

How can I rewrite these conditionals effectively?

I'm working on modernizing and adapting an old LuaLaTeX template made for exams and other university documents. The thing is, the document is full of conditionals like these: \newcommand{\showMarks}{...
2
votes
1answer
17 views

Notation for arguments by means of ifthen package

I have this idea to create a piece of code that would allow me for a handy introduction of arguments in my notes for students, by which I mean this kind of fractional notation: I need a command that ...
1
vote
1answer
29 views

Ifthenelse - Comparing strings (one inferior to another)

This topic is following my previous question, which was marvelously answered by BambOo yesterday. Now for a step beyond into this project. Let's admit I want to put a list of letters (or words) on a ...
0
votes
1answer
44 views

Remove space after \else inside command definition

I'm defining this command for my index: \newcommand*{command}{\iffirstsubsubitem\unskip\firstsubsubitemfalse\ \else; \fi} and I'm wondering if there is a way to eliminate the white space it prints ...
10
votes
4answers
566 views

How to test if the product of two numbers are positive as well as finding their absolute values?

I am trying to simplify my work with some latex coding, where the intention is to generate two types of diagrams based on the input. The first type is diagrams with lines only going up and the second ...
1
vote
1answer
17 views

conditional value in a hyperref textfield

I am trying to create a TextField whose value is conditional on a boolean. If the boolean is true, the default value in the TextField is some value; if it is false, the TextField starts blank (the ...
0
votes
0answers
23 views

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 ...
0
votes
1answer
39 views

Hiding an environment that contains minted code

Hello everybody and thanks for your time and effort. Task: I want to create a 'notes' command and an environment which can be hidden by a boolean flag. Problem: These 'notes' can contain minted code ...
3
votes
2answers
83 views

How to include if-else with computed variables in tikz

I am trying to plot some grids with each point circled in a certain color based on the coordinates. I find some code online to use ifthen package to include the if statement, the following code works ...
3
votes
2answers
84 views

How to select and print selected items from a list

I have written a solutions manual for a textbook and need to print only the odd numbered solutions. I formatted the text very simply with \enumerate within each section. Sample code: \begin{...
0
votes
1answer
65 views

Make a \newcommand argument optional without consequence

I have this code block in my .cls file - \newcommand{\ExperienceEntry}[5]{ \noindent\makebox[\width][l]{#1} \hfill \makebox[\width][l]{#2} \\ \noindent\makebox[\width][l]{#3} \hfill \\ ...
0
votes
1answer
82 views

Why does \ifdim work here but \if doesn't?

I'm very new to LaTeX, and need to compare a length I've defined with a default value (and set another length accordingly). Consequently, I'm exploring the murky (to me anyway) world of LaTeX ...
1
vote
1answer
48 views

How to set up a conditional loop that chooses which compiler to use within the same document?

I have a TeXlive 2019 installation with an unsolved problem that so far prevents me from compiling on this computer with LuaLaTeX, so I thought I could add to the preamble of the document that I'm ...
4
votes
2answers
59 views

How to apply \ifthenelse check on list member accessed via macro?

Hi and many thanks in advance! I'm trying to perfom an \ifthenelse check on an element, which was extracted out of a list using a macro found here. Unfortunately I cannot figure out how to do it: ...
4
votes
5answers
285 views

Having trouble with TikZ — For Loop and Conditionals

Essentially what I am trying to achieve is a grid of 12 circles with three rows and four columns. All I would like is for the two middle columns to be red while the other two columns are black. Here ...
1
vote
0answers
22 views

tikz variable value not change in foreach loop [duplicate]

Just for demo purpose, below logic only run into if clause but never run to else clause. \documentclass[tikz,border=2pt]{standalone} \usepackage{ifthen} \begin{document} \begin{tikzpicture} \...
1
vote
1answer
42 views

New command with cases / conditionals / 'if… then's

I defined a command to insert figures easier and according to some college formatting. It is working just fine, but I am having a problem trying to add a conditional statement. The command is this: %\...
2
votes
2answers
151 views

Automatically remove \ifthenelse

Let's assume that you have a single LaTeX source file that can compile two arts of documents: a main conference paper and its extended long version. Inside, you use \ifthenese to produce the two ...
0
votes
1answer
48 views

embedded command resulting in argument of \equal has extra } error

I am trying to make a macro (\ls) which will convert keywords into the mathmode version of their equivalent logic symbol. I've figured a way to make this work fine, except when it is in an argument of ...
0
votes
0answers
23 views

Changing command definition depending on the font size / location

Currently I define my multiplication with \newcommand{\m}{ \!\cdot\!}} but I would like to have the \! only there if the font is large enough. How do I check for the size of the font? The important ...
3
votes
1answer
154 views

How can I set boolean pgfkeys?

I am making a command called seal that needs a boolean key=value option. Since I don't know how to do this, I am using key=yes and key=no for defining my pgfkeys as follows. \pgfkeys{ /seal/.is ...
2
votes
1answer
58 views

Passing options from a newcommand to a another command (\includegraphics)

I'm making a command called \seal that uses the \includegraphics function. The command \seal has some key=value options of its own (color, beamer, trimz) and it must accept all options of \...
0
votes
1answer
35 views

How do I fix using the \ChapFrame; temporary removal and permanent attachment of the side thumb headings?

MWE \documentclass[a4paper,twoside,openright,10pt]{book} \usepackage{color} \usepackage{tikz} \usetikzlibrary{positioning} \usepackage[explicit]{titlesec} \usepackage{ifoddpage} \usepackage{lipsum} \...
1
vote
1answer
76 views

Implementing nested if-then-else tests

I would like to implement the following processsing for each row of my data, which is read with datatool: if ( (\No = 5 and \B=11111) OR (\No = 5 and \B=22222) ): \inserpageA else if ( (\No = 5) ...
0
votes
1answer
49 views

Sorting newcommands according to one variable

Two reviewers made several comments on my paper, and I am writing a response letter. I defined a newcommand as follows: \newcommand{\response}[3]{Comment by Reviewer #1 \\ Comment: #2 \\ Response: #3}...
0
votes
0answers
30 views

Using if in tables (spreadtab, tabu)

I was trying to build a document with a table which could change its rows depending on whether the customer needs to pay tax or not. I tried to go with http://handyfloss.net/2007.08/latex-programming-...
1
vote
1answer
59 views

if/else to test if a string is empty failing

Using the following \def \ifempty#1{\def\temp{#1} \ifx\temp\empty } \def \mymacro#1{ \ifempty{#1} empty \else not empty \fi } \mymacro{something} % prints "not empty" \mymacro{} % prints "...
1
vote
1answer
56 views

\ifthenelse statement inside includemedia options

I try to enable / disable some options for my 3D view with \ifthenelse. \documentclass[fontsize=12pt,paper=a4]{scrbook} \usepackage{media9} \usepackage{graphicx} \usepackage{ifthen} \begin{document} ...
0
votes
1answer
65 views

Set path using if / else

Depending on the previous text I need to set e path to folder 1 or folder 2. With just one folder everything worked fine, but with the condition it doesn't. What am I missing? \newcommand{\nc}{text-...
0
votes
0answers
40 views

I want to detect an order placed at the beginning of each theorem

I want to detect an order placed at the beginning of each theorem. \documentclass{article} \usepackage{ifthen,ntheorem} \newtheorem{ex}{Exam} \begin{document} \begin{ex} \LaTeX{} There is the LaTeX ...
4
votes
1answer
151 views

Random Numbers and Variables in Latex

Below is my MWE. I understand the gist of tikz and foreachs, but when it comes to variables I don't understand most yet. I want an arrow pointing from each cell to a module, and them from the module ...
3
votes
1answer
100 views

Display Box A or Box B if then condition

I am using datatool and want to display \posterbox A, hide box B if \TextA = value, if \TextA = blank display \posterbox B and hide box A. Box A & Box B are different: Image, item, color, ...
0
votes
1answer
29 views

Print only non-empty variables, with conditional punctuation

I have several variables. I need to print those that are not empty. The first variable printed must be preceded by some text. If there are multiple variables printed, they must be separated by ...
4
votes
2answers
57 views

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)...
5
votes
3answers
340 views

Expand `ifthenelse` immediately

Consider this script: \documentclass{report} \usepackage{ifthen} \newcommand{\thesissize}{SHORT} \begin{document} \setcounter{page}{ %3 \ifthenelse{ \equal{\thesissize}{SHORT} }{3}{...
2
votes
1answer
107 views

help with nomenclature groups and ifthenelse

I am grouping my nomenclature symbols. I'm using the answer from this post: How to make section in Nomenclature? The syntax I've used is this: \renewcommand{\nomgroup}[1]{% \ifthenelse{\equal{#1}...
2
votes
1answer
78 views

Use \ifthenelse{\equal{ on a number called from reference

I want to store an answer key for an exam and then automatically move the multiple choice answer choices around for each question match its predetermined answer. (I need to conform my multiple choice ...
1
vote
0answers
37 views

Conditionally include a line based on an option with pgfpackages

I am trying to design a small package, mostly for test purpose. Currently the package looks like this: % eqbox.sty \NeedsTeXFormat{LaTeX2e}[1994/06/01] \ProvidesPackage{eqbox}[2019/01/01 Boxed ...
3
votes
2answers
193 views

Detecting subscript in command argument

I have defined a command low that adds a subscript to an argument: \newcommand{\low}[1]{{#1}_{l_{\mathcal{A}}}} However, if the argument of low contains subscripts itsself (for example in the case ...
1
vote
0answers
61 views

\ifthenelse command when using expl3 syntax

What is the equivalent of \ifthenelse{<statement>}{<iftrue>}{<iffalse>} when using expl3 syntax?
2
votes
2answers
425 views

Proper if statement

I have real trouble getting an if statement to work properly.... here is a link to a zip file with all code needed: https://www.dropbox.com/s/ojsj33oe9ac4g09/latex-rechnung.zip?dl=0 My code: \...
1
vote
1answer
48 views

Ifthen statement with array value as an entry

Whenever I try to use an element of an array as an entry for a \ifthenelse statement I get the error Incomplete \iffalse; all text was ignored after line 6. Here's a MWE. \documentclass{memoir} \...
3
votes
1answer
149 views

Error by using changes (\listofchanges) with documentclass amsart

I want to use the package changes with the document class amsart, however, I get the following error message: ! Undefined control sequence. <argument> \equal {\Changes@loc@...
3
votes
1answer
118 views

Lost global definition after \ifthenelse using package xifthen

I created my MWE with the help of this Q&A. MWE: \documentclass{article} \usepackage{xifthen}% provides \isempty test \newcommand{\GlobalDef}[1][]{ % \ifthenelse{\isempty{#1}} % {} % ...
6
votes
3answers
574 views

Seven segment display with TikZ

Consider the following MWE: \documentclass[border=5pt,tikz]{standalone} \usepackage{ifthen} \newcommand{\binary}[3]{ \pgfmathsetmacro\number{int(#1*2^0+#2*2^1+#3*2^2)} } \newcommand{\sieben}[1]{ ...
2
votes
1answer
136 views

advancing dates in a 3-day syllabus

I am trying to adapt this advance date method for a 3-day syllabus without success. The goal is to create a M-W-F class schedule. The method in the link above is for a two-day schedule. It takes the ...
1
vote
2answers
166 views

Conflict with \fi in figure captions

I have the following preamble: \documentclass[11pt]{book} % PACKAGES % graphics packages \usepackage{graphics} \usepackage[pdftex]{graphicx} % negative phantoms (\nphantom, \nhphantom, \...
1
vote
1answer
79 views

Conditionals used in a new environment of detection of how many lines of quotation and with the selection of a language in XeLaTeX

I would like that a new environment of quotation/quote detect how many lines a text has, then will increase or decrease the quotation length/margin. For example: \newenvironment{citacao}[1]% {\...
2
votes
1answer
92 views

Indentation of footnotes depending on number of digits in footnote marks on the same page

I wanted to adjust the left indentation of footnotes depending on the number of digits of the footnote mark. Thus, footnotes with one digit are aligned a the length of single \parindent (which is set ...
1
vote
1answer
60 views

How do I get permission for exam materials?

MWE \documentclass{minimal} \usepackage{ulem} book = 1 phone = 0 photocopy = 1 internet = 0 tablet = 1 \begin{document} Book, \xout{phone}, photocopy, \xout{internet}, tablet, \ldots\ free or open. ...