Questions tagged [ifthenelse]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
21 views

Define new environment with conditions

I would like to define a new environment with conditions in my template file. My environment consists in a lign of header filled by a title (given at the environment in an argument) and then at the ...
1
vote
2answers
31 views

Allowed Algebra with \the\year

I have a homework problem that I reuse relatively frequently, and I'm trying to update the solution to match the dynamic. Suppose z(t) is a periodic function with period 3. Evaluate z(\the\year). \...
2
votes
1answer
49 views

Simple toggle animation won't work

I tried a simple toggleanimation. First i create a bool value If I set it to true, the if path is performed, set it to false results in the else path. So far so good. Within an animateinline i want to ...
1
vote
1answer
33 views

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} \usepackage{textcomp} \usepackage{mathpazo} \usepackage{eulervm} \usepackage[utf8]{...
1
vote
1answer
47 views

Pgfplots - conditional style

I would like to create a conditional style for my pgfplots graph that would use this or that elementary style, based on an input value. Here is an example of a conditional style depending on the value ...
3
votes
1answer
41 views

Conditional header appearance based on chapter name

I am converting a complex markdown document to pdf using pandoc. And need to add some formatting to it during the conversion. So I cannot have the styling and the data at the same place, means, I ...
0
votes
0answers
26 views

Using a variable (?) to change color definition on STY file

I am trying to use a variable I define with \newcommand in a tex file (\profile) in an if-else loop to define a color (\main_color) in the style-file I am using. So when \profile is np \main_color ...
0
votes
1answer
41 views

Unexpected TikZ ifthenelse behavior [duplicate]

The TikZ user guide (version 3.18b, page 1042) says this: ifthenelse(x,y,z) This returns y if x evaluates to some non-zero value, otherwise z is returned. It would appear that both y and z are first ...
0
votes
1answer
20 views

How to define a macro containing if without closing fi, and another macro containing the closing fi

I am working on a LaTeX document and writing at several locations. For faster compiling, I have surrounded some sections with \iffalse, \fi constructs. When I proof-read the document at the end of the ...
0
votes
1answer
71 views

Detect segment intersections with tikz

I have to detect when two segments intersect in a parametric figure that need's to computes coordinates into a tikz picture, and it won't works, seem's that "intersections=... total=\t" or &...
1
vote
1answer
49 views

The format of if-else in the function is wrong

When using latex to write pseudo-code, using loops in the function, the vertical line position is wrong. \usepackage[ruled,lined]{algorithm2e} \usepackage{algorithmicx} \usepackage{algpseudocode} \...
3
votes
2answers
81 views

Add a different Spanish definite article to a cross-reference depending on the kind of theorem it refers to

I'm using the package cleveref to automatically print the name of the kind of "theorem" of a reference via the \Cref macro. Since I'm writing in Spanish, the most natural way to refer to a ...
0
votes
0answers
30 views

Calculated solution is not recognized as value

In the code below it should be checked if treq<t. In TEST 1, treq is specified as 2.93. The condition treq<t is met and turns blue (or red). \ifthenelse condition works fine. In TEST 2, xreq is ...
3
votes
1answer
146 views

ifthenelse adds undesired space

In the following fragment, my use of \ifthenelse in a \newcommand adds a space: \documentclass[letterpaper]{article} \usepackage{ifthen} \usepackage{graphicx} \newboolean{color-version} \setboolean{...
4
votes
2answers
57 views

if-condition for next command

After I started building my own environments, I was wondering, if there is a if-condition, that checks what the next command is, and then gives the option to run something before the next command. A ...
1
vote
1answer
73 views

How can I replace the ifthen package in this TikZ/PGF command?

I would like to modify a command so that it doesn't need the ifthen package not necessarily because of this, Why is the ifthen package obsolete?, but just to used the funcationality in Tikz/PGF. The ...
0
votes
2answers
49 views

If else condition in document to control format of equation

How can I create a variable in the beginning of the latex document that will dictate how certain equation will be shown? Concretely, in the beginning I want to define a variable x which will take ...
2
votes
1answer
34 views

Use width of certain block of text as parameter

I wonder if it's possible to get the width of a certain block of text, passed as an argument in \newcommand and use it numerically inside a conditional. For example, defining a \newcommand which ...
0
votes
0answers
40 views

if statement in nested foreach in tikzpicture not working - wrong syntax?

I attempt to place dots on certain grid locations by using a nested \foreach command as follows, but TeXstudio rejects the use of the second variable \y with an error 'unrecognized command'. Strangely ...
2
votes
1answer
45 views

Problem with a test in if statement

I'm having trouble with the implementation of a if statement. I want to know if today and five days from now happen in the same month. I get the correct values of the corresponding month to print but ...
0
votes
0answers
117 views

Shorthand or simplified boolean expressions?

I have a lot of self-defined booleans and conditional statements, and have conditions like \ifthenelse{\NOT \boolean{foo} \AND \NOT \boolean{bar} \AND \NOT \boolean{baz}}{...}{...} I want a way to ...
0
votes
2answers
47 views

String comparison on \citefield result

I'm using \citeall with a custom entry formatter to list all the entries in my bib file, but I'd like to conditionally format entries from a specific journal. To do this, I've tried using \ifthenelse ...
1
vote
1answer
105 views

On the xfp package: Comparison

On page 1/2 of the xfp package we read: The floating point expressions may comprise:Comparison operators: x < y, x <= y, x >? y, x ! = y etc. However they did not show an example. Below I ...
5
votes
4answers
321 views

On a conditional command: more powerful than \ifnum

According to the TEX in a Nutshell, Petr Olšák, page 16/29, we get: \ifnum ⟨number 1⟩ ⟨relation⟩ ⟨number 2⟩ . The ⟨relation⟩ could be < or = or >. It returns true if the comparison of the two ...
2
votes
1answer
114 views

Typography of nested quotations

In the case of nested quotations, we have the following rule in French typography: if two or more closing quotation marks follow one another, we will write only one closing quotation mark. Thus: « ...
2
votes
2answers
34 views

Why does \substring not work inside \equal?

Why does this code output "False": \documentclass{article} \usepackage{stringstrings} \usepackage{xifthen} \begin{document} \ifthenelse{\equal{\substring{ab}{1}{1}}{a}}{True}{False} \end{...
0
votes
1answer
42 views

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}{ \...
1
vote
1answer
40 views

Problem expanding arguments

I have a problem of understanding how expanding works. I have been reading several posts but none of them solve my problem. I have been trying to do something like this: \documentclass{article} \...
1
vote
1answer
65 views

Check for empty tex file to decide ifthenelse branch

Objective: I am trying to key on on the presence of file content (comments are acceptable, I am trying to key in on content that would be displayed in the built PDF) to determine what path to take. If ...
1
vote
1answer
30 views

Error using `\ifthenelse` from `xifthen` in theorem optional arg, with package `thm-restate` loaded

I want to put a conditional of the form \ifthenelse{\isempty{…}}{…}{…} in the optional argument of an amsthm-style theorem. Ordinarily, this works fine, but the package thm-restate (from thmtools) ...
4
votes
2answers
125 views

ifthen + [ngerman]babel + pgfplots + axis + text height = ☇

Continuing [ngerman]babel + pgfplots + axis + text height = ☇ and feeding \RequirePackage{ifthen} \newboolean{techrep} \setboolean{techrep}{true} \documentclass{article} \usepackage[ngerman]{babel} \...
1
vote
1answer
61 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
81 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
92 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
50 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
600 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
46 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
35 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 ...
2
votes
2answers
79 views

Hiding an environment that contains minted code

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 blocks which mess up previous solutions found on the ...
3
votes
2answers
282 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
139 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
98 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
151 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
66 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
70 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
350 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
51 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
171 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
70 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 ...