Questions tagged [ifthenelse]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
50 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 &...
2
votes
1answer
38 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
76 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
29 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
129 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{...
3
votes
2answers
50 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
71 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
44 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
29 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
1answer
75 views

Undefined control sequence. l.12 \NeedsTeXFormat {LaTeX2e}

I've recently updated texmaker and miktex and my latex template for writing application letters doesn't work anymore. (latex template Error message: ("C:\Users\Admin\AppData\Local\Programs\...
0
votes
0answers
32 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
40 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
60 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
37 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
81 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
277 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
111 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
26 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
32 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
38 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
63 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
29 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
124 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
56 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
43 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
57 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
48 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
592 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
33 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
27 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
56 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
174 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
122 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
85 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
123 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
61 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
66 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
335 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
50 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
167 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
61 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
31 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
234 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
76 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
40 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
122 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
50 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
35 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
95 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 "...