Questions tagged [xifthen]
{xifthen} is for questions addressing issues related to conditionals using package xifthen.
63
questions
1
vote
1
answer
69
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 ...
3
votes
1
answer
84
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 ...
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}
\...
2
votes
1
answer
115
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 ...
4
votes
2
answers
700
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 ...
2
votes
2
answers
150
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{...
1
vote
1
answer
38
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) ...
1
vote
1
answer
45
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 ...
0
votes
1
answer
638
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 ...
0
votes
1
answer
209
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 ...
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 ...
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|}
...
3
votes
2
answers
445
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 ...
3
votes
1
answer
399
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@...
4
votes
3
answers
422
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 ...
3
votes
1
answer
147
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}} %
{} %
...
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 = ...
15
votes
2
answers
25k
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 ...
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. ...
5
votes
1
answer
885
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 ...
0
votes
1
answer
144
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 ...
3
votes
1
answer
271
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 ...
3
votes
2
answers
172
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]{ ...
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{...
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={},...
1
vote
1
answer
450
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 ...
0
votes
0
answers
878
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/...
0
votes
1
answer
785
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[...
2
votes
2
answers
370
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:
\...
6
votes
1
answer
659
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 ...
3
votes
1
answer
200
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 ...
1
vote
1
answer
100
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 ...
2
votes
0
answers
892
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 ...
17
votes
5
answers
710
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 ...
4
votes
2
answers
517
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....
2
votes
1
answer
75
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}
\...
11
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 ...
6
votes
6
answers
549
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}{...
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}
...
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 ...
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 ...
3
votes
1
answer
649
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. ...
2
votes
2
answers
373
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 ...
5
votes
2
answers
299
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]{...
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]{
\...
2
votes
1
answer
256
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 ...
1
vote
2
answers
108
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 ...
3
votes
2
answers
438
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}}%
{}% ...
2
votes
1
answer
412
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 ...
3
votes
1
answer
318
views
How to automate introduction of section titles in book
I'm using Spundun's method for automating inputing the entries in a diary, in turn inspired by Peter Grill (Using LaTeX to keep a diary), and I would like to add section dividers by year. This should ...