Questions tagged [ifthenelse]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
86 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 ...
user avatar
1 vote
3 answers
35 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 ...
user avatar
  • 640
4 votes
2 answers
97 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, ...
user avatar
0 votes
0 answers
41 views

Error "Extra \else" statement with "ceurart"

I am getting an error when I run pdflatex command on the following .tex document. \documentclass[ % twocolumn, % hf, ]{ceurart} \usepackage{minted} \setminted{breaklines=true} \def\UrlBreaks{\do\/\...
user avatar
  • 37
0 votes
1 answer
48 views

Assign a color to a variable name in a newcommand

I am writing a complex diagram using TikZ in which the colors used for certain nodes depend on the value of the input variable. I cannot use the color itself as an input variable as certain things ...
user avatar
  • 1,030
0 votes
1 answer
31 views

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[...
user avatar
2 votes
1 answer
34 views

newif for table does not work

I create two different table contents and want to switch with a newif. \AAAfalse has no effect. What do I have to do? \documentclass[a4paper, landscape]{article} \usepackage{pgfplotstable} \...
user avatar
  • 6,217
0 votes
0 answers
19 views

Use scale if latex image is small enough, center in page otherwise [duplicate]

I automatically generate a bunch of diagrams, and I'd like them to be automatically formatted to fit the page according to the following style: If the diagram (in the form of a .png figure) is ...
user avatar
  • 185
2 votes
1 answer
54 views

Why does \ifthenelse not work?

Im currently dealing with a problem in my code. I keep getting the error use of \nextx does not match its definition From the \pgfmathsetmacro\nextAsInt... line. But i cant see the problem. It should ...
user avatar
1 vote
0 answers
46 views

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 ...
user avatar
  • 133
2 votes
1 answer
109 views

Extra \else and extra \fi error

I am writing a document that presents different information depending on a defined command. The code in a simple version is like this: \documentclass{article} %\usepackages ... \title{My title} \...
user avatar
5 votes
2 answers
107 views

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 ...
user avatar
1 vote
0 answers
53 views

String equality check [closed]

I want to compare 2 strings and perform different tasks based on their results(using if-else loop) My code is here: \tab• \hyperlink{new}{New Features, Enhancements, and Changes}\linebreak \begin{...
user avatar
  • 23
0 votes
1 answer
67 views

IF statement in .cls file. How to control it from .tex file?

Minimum working code is attached herewith. If I change 1 to 0 in \newcommand{\numsections}{1}, I get heading without number, and to get numbered heading, I have to go to .cls file. I don't want the ...
user avatar
4 votes
2 answers
128 views

Weird error: "\csname if@chapter@pp\endcsname" inside of \if ~ \fi

I can't understand why the following doesn't work: \documentclass{beamer} \newif\iftemp \tempfalse \iftemp \csname if@chapter@pp\endcsname \addcontentsline{toc}{part}{Appendices} \...
user avatar
4 votes
2 answers
106 views

How can I use integers as parameters for \ifcase

I am very confused about LaTeX's calculatation. I tried to defined an environment which could change its typography through an integer parameter I give freely. I chose \ifcase and tried as below: \...
user avatar
0 votes
1 answer
34 views

fix for texMemo class producing watermark when it shouldn't

I am starting to play with the texMemo document class (which can be found here). The class uses the ifthen package and the draft watermark package. I'm used the latter before but not the former. I ...
user avatar
  • 103
2 votes
1 answer
36 views

Conditionally formatting numbers using a \newcommand

I want to create a command the prints a number in red if its negative and green if it is positive. I have tried: \documentclass{article} \usepackage[dvipsnames]{xcolor} \usepackage{ifthen} \...
user avatar
0 votes
0 answers
37 views

XeLaTeX Awesome CV - conditionally add hyperlink to title text

I'm using font-awesome package for icons in my resume I want to add hyperlinks to few titles, examaple Link to Job Experience Certificate will be included in text if the URL is provided What I tried ...
user avatar
1 vote
2 answers
73 views

Algorithm2e - write IfThenElse in one line

I have the following example \documentclass{report} \usepackage{algorithm2e} \begin{document} \begin{algorithm} \lIf{$\max_{\mathcal{AV}} > \theta_5$} { \...
user avatar
  • 367
0 votes
1 answer
24 views

Condition for if the page is one sided

I want to do something like below \documentclass[a4paper, 12pt, oneside]{article} \begin{documnet} \if@twoside The page is doublesided. All good. \else \textbf{{\Huge The page is not double sided! ...
user avatar
  • 121
9 votes
1 answer
185 views

If condition with non integer numbers in Tikz

I have the following code to build the derivates of a given function: \documentclass[tikz, border=.5cm]{standalone} \usepackage{tkz-fct} \usepackage{xfp} \usetikzlibrary{spy} \definecolor{vinho}{rgb}{...
user avatar
4 votes
3 answers
307 views

Creating new environment with ifthenelse

I want to make it so all proofs in my document are conditional using the ifthen package. So far I have \usepackage{ifthen} \newboolean{proofs} \setboolean{proofs}{true} ... \ifthenelse{\boolean{...
user avatar
0 votes
1 answer
28 views

Nesting macros : probme with ifnum

I'm designing 2 macros, and nesting them fails and I can't see where I've made a mistake. The 1st macro takes a floating point number (eg 3.2) and check it agains 3 thresholds. The second macro ...
user avatar
  • 1,955
2 votes
1 answer
105 views

Graph of Thomae function by an amateur

I am trying to plot the Thomae function, which is defined in the following way: Now, I went through this answer, but unfortunately, could not grasp much. My idea is simple. Run two nested loops for ...
user avatar
2 votes
1 answer
38 views

New command using if/then statement based on cleveref values?

I have a special command defined called \Exerref which works on labels, much like \Cref. Would it be possible to create a new command, let's call it \Sref, that invokes either \Exerref or \Cref based ...
user avatar
  • 2,795
0 votes
0 answers
24 views

How to adapt titlespacing to odd or even pages

\documentclass[a4paper,12pt,twoside]{report} \usepackage{titlesec} \titleformat{\chapter}[display]{}{\chaptername}{-2pt}{\hskip5cm \centering \Huge \bfseries \mbox} \titlespacing{\chapter}{0pt}{-...
user avatar
1 vote
1 answer
41 views

\whiledo not working when using it to generate table

I'm trying to use \whiledo (contained in the ifthen package) to automate the creation of a table. The idea—more or less—is that by setting a value \colnum to a number x, I can make a table with x+1 ...
user avatar
0 votes
0 answers
31 views

Using references to line numbers of lineno package to do calculations

In a text with lines numbered (page-wise and every five lines) I would like to place labels into the text and then use the line numbers of those places for the following calculation: I'm marking a ...
user avatar
  • 1,750
0 votes
0 answers
23 views

Defining environments with options (Options may or may not be available)

I define a new environment as my code below. The compilation results are not correct with the options of this environment. The option of the second is used for the third, The option of the third is ...
user avatar
0 votes
1 answer
39 views

Return type for \newcommand probably doesn't fit \DTLfetch?

I want to fetch from the csv file with a boolean condition (either give me the fruit or give me the count). The first command (CMDone) works and says "count" and the fetch also works and ...
user avatar
4 votes
1 answer
62 views

Generate an error message when the result of a command is empty

I have the following sample code: \documentclass{article} \usepackage{etoolbox} \newcommand{\defineSpecies}[2]{\csdef{spec@#1}{#2}} \newrobustcmd{\spec}[1]{\csuse{spec@#1}} \defineSpecies{h2o}{H$_2$...
user avatar
  • 512
0 votes
1 answer
52 views

PGF/Tikz Ifthenelse complaining about missing num

This MWE \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture}[ overline/.style={black,fill}, underline/.style={black,fill=white}] \pgfmathsetmacro{\Px}{2} \...
user avatar
  • 1,007
3 votes
1 answer
26 views

Executing only specific options

I'm pretty new to advanced LaTeX coding and therefore may not have a perfectly specific question. I hope you can help me anyway: I want to maintain different preambles at once. They can be seen as ...
user avatar
  • 366
1 vote
1 answer
110 views

How to change the index in a foreach loop depending on the index value

I this example: \documentclass[border=2mm]{standalone} \usepackage {tikz} \usepackage {siunitx} \usetikzlibrary{3d} \usetikzlibrary{babel} \usetikzlibrary{calc} % \usepackage{...
user avatar
  • 273
0 votes
1 answer
187 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 ...
user avatar
  • 1
1 vote
2 answers
33 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). \...
user avatar
  • 119
2 votes
1 answer
65 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 ...
user avatar
  • 113
1 vote
1 answer
54 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]{...
user avatar
2 votes
1 answer
72 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 ...
user avatar
  • 281
3 votes
1 answer
103 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 ...
user avatar
0 votes
0 answers
41 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 ...
user avatar
  • 101
0 votes
1 answer
50 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 ...
user avatar
  • 7,683
1 vote
1 answer
40 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 ...
user avatar
0 votes
1 answer
83 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 &...
user avatar
1 vote
1 answer
70 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} \...
user avatar
  • 227
4 votes
2 answers
98 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 ...
user avatar
  • 139
0 votes
0 answers
41 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 ...
user avatar
  • 21
3 votes
1 answer
197 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{...
user avatar
  • 2,855
4 votes
2 answers
70 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 ...
user avatar
  • 366