Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [xifthen]

{xifthen} is for questions addressing issues related to conditionals using package xifthen.

Filter by
Sorted by
Tagged with
1 vote
0 answers
22 views

Using \ifthenelse and \isempty in newcommand used in glossaries's name

I want to use \ifthenelse while defining symbols with \newcommand. This works all fine, until I try to use those symbols (here \densCanv) in my glossary as a name: \documentclass[a4paper,10pt]{article}...
Make42's user avatar
  • 1,812
1 vote
1 answer
102 views

Conditioning tcolorbox options/type on box content—fit or break depending on fitted text size

I'm using tcolorbox to make some 3x5 cards with lots of text on them. These cards usually consist of a few boxes that don't change much and one final box (containing descriptive text) that fills the ...
Victoria Stephens's user avatar
3 votes
1 answer
104 views

\nameref and xifthen's \isempty do not work properly

So, I made a macros \fullref and combined it with \ifthenelse to remove [] if no content were printed. But when, for example, theorem has no name, \nameref prints nothing but xifthen's \isempty do not ...
Vladyslav Rehan's user avatar
2 votes
1 answer
37 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} \...
scaramouche's user avatar
2 votes
1 answer
122 views

tex4ebook: issues with xifthen functions if biblatex is imported

I'm trying to generate an .epub with tex4ebook. One of the commands I've defined uses \ifelsethen and \isempty to check for empty parameters and produce different output depending on which parameters ...
avren's user avatar
  • 133
4 votes
2 answers
822 views

Use xifthen package to determine if optional argument is provided

I am trying to create a command test that takes 3 arguments. The first argument is optional, while the second and third arguments are mandatory. I am trying to use the xifthen package, and ...
Andrew's user avatar
  • 1,269
2 votes
2 answers
185 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{...
Jakob's user avatar
  • 1,003
1 vote
1 answer
39 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) ...
Peter LeFanu Lumsdaine's user avatar
1 vote
1 answer
50 views

How to create an automated presentation showing determined graphics

I am a maths teacher trying to make an automated slide to use as students come into my class. The aim is to revisit topics that we have learnt previously and I am taking photos of questions at the end ...
Nikel King's user avatar
1 vote
1 answer
782 views

Use multi ifthenelse equal text

In the question Use xifthen: how set \cnttest not equal number, I learnt how to perform if-then-else tests where the condition compares two integers. Now, I would like to do the same, but with string ...
latexforti's user avatar
  • 2,111
0 votes
1 answer
238 views

Use xifthen: how set \cnttest not equal number

i read user manual of xifthen package. But i don't find "Not equal" command. How can i set below rule: \ifthenelse \cnttest{\Var} equal A: Do newcommand AAA \ifthenelse \cnttest{\Var} equal B: Do ...
latexforti's user avatar
  • 2,111
0 votes
0 answers
45 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 ...
Anh Tuấn Trần's user avatar
4 votes
3 answers
2k views

\ifthenelse do nothing

I want to define a table as command. Some lines schould only be printed, if there is a value for it. Because of that I am using the \ifthenelse command. Example: \begin{tabularx}{\linewidth}{|l|X|} ...
NelDav's user avatar
  • 658
3 votes
2 answers
496 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 ...
Rincewind's user avatar
3 votes
1 answer
422 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@...
DerJFK's user avatar
  • 473
4 votes
3 answers
451 views

Detect empty or null output from xstring's StrBetween

I have some code for formatting names. However, the ifempty macro from xifthen is unable to detect empty/null output from xstring macros such as StrBetween. The same goes for the \equal {} method. How ...
Adam Erickson's user avatar
3 votes
1 answer
150 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}} % {} % ...
jed's user avatar
  • 235
5 votes
3 answers
1k views

What is wrong with the use of `isodd` of `xifthen`?

The white/black board can be drawn by testing the parity of node positions as follows: \documentclass[tikz]{standalone} \usepackage{xifthen} \begin{document} \begin{tikzpicture}[every node/.style = ...
hengxin's user avatar
  • 2,391
16 votes
2 answers
31k views

How test value of a command with `\ifthenelse` and `\equal`?

Revised question (Trying to follow suggestion in comment by David Carlisle.) I want to assign a string as the value of a command and then take alternative actions (by means of ifthenelse) according ...
murray's user avatar
  • 8,712
2 votes
2 answers
1k views

Conditional If-then-else/xIf-then-else Packages

I'm currently working on a presentation about the packages mentioned in the title. The problem I have is, I don't really understand why anyone would use conditional statements in a LaTeX document. ...
zebck's user avatar
  • 137
5 votes
1 answer
1k views

If Statements in Biblatex

Having spent many hours poring over examples and documentation, I have finally got my references almost up to what I require (yay!). There are still a few bits that I cannot manage, and I'm hoping ...
Sam OT's user avatar
  • 1,338
0 votes
1 answer
154 views

section title with IfStrEq formula in \sethead

I want to include in \sethead the section title. I use \IfStrEq formula like this: IfStrEq{\bottitlemarks\sectiontitle}{\firsttitlemarks\sectiontitle}{\firsttitlemarks \sectiontitle}{\firsttitlemarks ...
Marek Jurczyga's user avatar
3 votes
1 answer
285 views

Piping a return value from one command to another command

I am making some elaborate truth tables, and I want to be able to define the further columns in terms of the initial few atomic variables, so that I don't manually have to update the whole thing for ...
axolotl's user avatar
  • 143
3 votes
2 answers
188 views

Error when checking for empty list element

When I run this MWE \documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{ifthen} \usepackage{xifthen} \usepackage{etoolbox} \newcommand{\Entry}[6][\textwidth-3cm-16pt]{ ...
Make42's user avatar
  • 1,812
1 vote
1 answer
71 views

Including xifthen package breaks macro expansion in header

In the following MWE, I build a 'database' which I then query later in body text and in headers. It works fine until I load the xifthen package. This is not used in the MWE, but I do use the \isempty{...
K.G. Feuerherm's user avatar
5 votes
2 answers
1k views

etoolbox instead of ifthen

I try to realize this with etoolbox instead of ifthen. What I have so far... \documentclass{article} \usepackage{tikzpagenodes} \usetikzlibrary{calc} \usepackage{etoolbox} \usepackage[contents={},...
Andreas Schneider's user avatar
1 vote
1 answer
504 views

If-then-else condition for print argument of a command

I am a beginner in latex and I've some problem on implementing an 'if-then-else' condition in LaTEX. In particular, I've tried to print an argumen when it is passed in the command \newenvironment and ...
Albert's user avatar
  • 37
0 votes
0 answers
980 views

Changing a boolean in a class file from the main latex file

I'm trying to change a boolean value located in a class file (.cls) from the main latex document (.tex). I've tried to set the boolean in the main latex file using \setboolean{showwatermark}{true/...
coatless's user avatar
  • 401
0 votes
1 answer
850 views

Etoolbox package : example

How to replace the C-like code ? \documentclass{book} % C-like code : #define FinalCompilationBooleanIsOn 1 % C-like code : if FinalCompilationBooleanIsOn { \usepackage{pst-all} \usepackage[...
thomasb's user avatar
  • 175
2 votes
2 answers
466 views

Multiple errors when setting label using a command

I defined a command to create a section with a label. Depending on whether only one or both arguments are used, the section name and label can be different. I created the following MWE: \...
Robin Hartmann's user avatar
6 votes
1 answer
667 views

Ifthenelse fails if is part of argument

I have followed very simple tutorial to create own listof. Link is https://texblog.org/2008/07/13/define-your-own-list-of/ It worked great, I just wanted to add optional parameter. If this optional ...
Arxeiss's user avatar
  • 163
3 votes
1 answer
203 views

Can I make a switch-like conditional environment?

I'm writing a running presentation for an entire semester's lecture (with beamer) and would like to make an environment such as \begin{lecture}{3} ... \end{lecture} such that I can have at the top ...
DanielGr's user avatar
  • 131
1 vote
1 answer
122 views

Certain conditions including commands resulting false

I'm having a really hard time understanding why the following \ifthenelse check will always result false. I already used strings and commands in my conditionals and I know that they work. In this ...
il mietitore's user avatar
2 votes
0 answers
960 views

ifthenelse no else with string comparison [closed]

Answer below Issue I am using the package xifthen to try and check if a string variable is equal to a specific string in order to input something. I only want to do something in case the test is ...
Akaizoku's user avatar
  • 608
17 votes
5 answers
747 views

Test if the value of a counter belongs to a given list of values

This must be a LateX 101 question, so I ask for your kindness I want to make a choice based on the value of a theorem counter. I use the xifthen package (especially the \isin function, which tests ...
jm.ferrard's user avatar
4 votes
2 answers
544 views

Why does xifthen not work with this beamer code?

I am attempting to use \isempty to decide if a macro argument is empty. It works fine with book, but gives an error message with beamer: ! Undefined control sequence. <write> ...[]{Outline0.0.1....
katang's user avatar
  • 1,439
2 votes
1 answer
81 views

Compile error when using if in my environment

I have a custom environment with some parameters. The goal is to basically layout some parameters of the environment. My simplified document is this: \documentclass[11pt, a4paper]{article} \...
Yves V.'s user avatar
  • 179
12 votes
3 answers
2k views

if test for 1 not 11

It may seem rather silly, but I can't find an answer for this question. (I've been looking for one for a while already). Suppose I want to have a macro with a single parameter. When this parameter ...
Rafael's user avatar
  • 244
6 votes
6 answers
562 views

How to write macro with variable amount of text variables

I am trying to make a signature block macro that accepts a variable number of text variables so that I can add or subtract the text without using empty fields "{}" as arguments. \sigblock{0}{2}{...
A Feldman's user avatar
  • 3,955
7 votes
3 answers
8k views

String comparison

\documentclass{article} \usepackage{xifthen, xstring} \newcommand{\IfOne}[3]{ \if\TokenIsIn#1 #2 \else #3 \fi } \newcommand{\IfTwo}[3]{ \ifthenelse{\equal{\TokenIsIn}{#1}}{#2}{#3} ...
Miheer's user avatar
  • 173
5 votes
1 answer
4k views

Using a command (or a variable) in if/then condition

Imagine the following situation: A school offers two courses, course A and course B. One of the courses is math and the other is physics. Math is taught by Bill, and physics is taught by Susan. I want ...
ashpool's user avatar
  • 1,361
6 votes
1 answer
2k views

\left( and \right) with maximum size

I would like to have two macros that mimic \left( and \right), but limits the size of the parenthesis to \Bigl( and \Bigr) (allows smaller sizes), respectively. In the below MWE, one needs to extend ...
Ritz's user avatar
  • 946
3 votes
1 answer
659 views

ifthen and spreadtab

I use the spreadtab and the xifthen packages for computing percentiles, but I found an unusual behavior. I give an example of false result: a true command remains false when it's used in a spreadtab. ...
Faouzi Bellalouna's user avatar
2 votes
3 answers
405 views

lastpage, hyperref and xifthen

I am trying to write a code for figuring if the current page is the last page. I do run into some problems, though. In my example here, the code will not run if hyperrefis loaded. Without it, it ...
Runar's user avatar
  • 6,092
5 votes
2 answers
305 views

Branching statement issue (TikZ)

I am using a branching statement in a tikzpicture as presented in the TikZ & PGF Manual (p. 634). Here is a MWE : \documentclass{article} \usepackage[letterpaper,textwidth=8.5in,textheight=11in]{...
Melian's user avatar
  • 1,238
4 votes
3 answers
2k views

How to easily write conditional pages? [closed]

Is there any easy way to make latex write only some of the pages? My current idea is to make a function using the ifthen-package in the following way: \newcommand{\WhatDoYouWantToWrite}[1]{ \...
user7919's user avatar
2 votes
1 answer
258 views

Requirements and inputvalidation

I want to recreate my current makros to work in every document. Currently I am working on the task, if a package is loaded, the command will be provided as desired. Look at the following MWE, which ...
Peter Ebelsberger's user avatar
1 vote
2 answers
110 views

Tracking revisions with external txt file

I made the following code to add a revision number to my latex header. I rely on a .txt file, which is assumed to exist in the same directory. always have a number. Anything else will probably make ...
melkhaldi's user avatar
  • 375
3 votes
2 answers
443 views

Conflict between xifthen and fixme?

Given the following MWE: \documentclass[draft]{scrbook} \usepackage{xifthen} \usepackage{fixme} \newcommand\needscitation[1][]{% \fxwarning{citation needed% \ifthenelse{\isempty{#1}}% {}% ...
retorquere's user avatar
  • 1,508
2 votes
1 answer
428 views

Retrieving text from a "database text" file

I refer to my question and the solutions in String comparison in \ifthenelse I hope I can make my question clear enough, I am not a technician. I use a kind of database file (simple text file) with ...
Christof's user avatar
  • 460