Questions tagged [xifthen]

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

Filter by
Sorted by
Tagged with
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
2 votes
1 answer
70 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 ...
user avatar
  • 123
3 votes
2 answers
343 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 ...
user avatar
  • 1,147
2 votes
2 answers
54 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{...
user avatar
  • 721
1 vote
1 answer
35 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) ...
user avatar
1 vote
1 answer
38 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 ...
user avatar
0 votes
1 answer
386 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 ...
user avatar
  • 1,921
0 votes
1 answer
158 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 ...
user avatar
  • 1,921
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 ...
user avatar
4 votes
3 answers
1k 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|} ...
user avatar
  • 608
3 votes
2 answers
340 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 ...
user avatar
3 votes
1 answer
330 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@...
user avatar
  • 433
4 votes
3 answers
299 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 ...
user avatar
3 votes
1 answer
140 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}} % {} % ...
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 = ...
user avatar
  • 2,239
14 votes
2 answers
14k 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 ...
user avatar
  • 6,538
2 votes
2 answers
695 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. ...
user avatar
  • 137
5 votes
1 answer
603 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 ...
user avatar
  • 1,157
0 votes
1 answer
124 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 ...
user avatar
3 votes
1 answer
229 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 ...
user avatar
  • 143
3 votes
2 answers
131 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]{ ...
user avatar
  • 1,662
1 vote
1 answer
67 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{...
user avatar
5 votes
2 answers
896 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={},...
user avatar
1 vote
1 answer
333 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 ...
user avatar
  • 37
0 votes
0 answers
652 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/...
user avatar
  • 381
0 votes
1 answer
518 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[...
user avatar
  • 175
2 votes
2 answers
271 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: \...
user avatar
6 votes
1 answer
600 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 ...
user avatar
  • 163
3 votes
1 answer
181 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 ...
user avatar
1 vote
1 answer
84 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 ...
user avatar
2 votes
0 answers
774 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 ...
user avatar
  • 588
16 votes
5 answers
614 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 ...
user avatar
4 votes
2 answers
461 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....
user avatar
  • 1,377
2 votes
1 answer
70 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} \...
user avatar
  • 179
11 votes
3 answers
1k 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 ...
user avatar
  • 234
6 votes
6 answers
482 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}{...
user avatar
  • 3,930
6 votes
3 answers
6k 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} ...
user avatar
  • 163
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 ...
user avatar
  • 1,341
5 votes
1 answer
1k 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 ...
user avatar
  • 886
3 votes
1 answer
618 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. ...
user avatar
2 votes
2 answers
322 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 ...
user avatar
  • 5,932
5 votes
2 answers
278 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]{...
user avatar
  • 1,138
4 votes
3 answers
1k 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]{ \...
user avatar
2 votes
1 answer
234 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 ...
user avatar
1 vote
2 answers
96 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 ...
user avatar
  • 345
3 votes
2 answers
431 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}}% {}% ...
user avatar
  • 1,313
2 votes
1 answer
387 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 ...
user avatar
  • 450
3 votes
1 answer
278 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 ...
user avatar
14 votes
2 answers
2k views

String comparison in \ifthenelse

I want find a certain line of text in a data file cities.txt: A;London B;Berlin C;Paris with the xstring and [xifthen][2] packages: \documentclass[12pt, a4paper]{article} \usepackage{xstring} \...
user avatar
  • 450
5 votes
1 answer
808 views

Using `ifthenelse` to combine two related functions into one

This question is based on Peter Grill's answer to "Table including rows of a master table".. The function PrintDTLTable was in Peter's original answer. I wanted a version that would run over all rows,...
user avatar
  • 7,424