Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [xifthen]

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

0
votes
0answers
13 views

Use output of external command in xifthen

It would like to call the kdb command from Elektra from within LaTeX documents and use its output to write LaTeX conditionals. Ideally, I would like to have something like: \documentclass{article} \...
2
votes
3answers
53 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|} ...
2
votes
2answers
126 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
1answer
94 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
3answers
129 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
1answer
63 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
3answers
315 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 = ...
5
votes
2answers
185 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
2answers
136 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. ...
4
votes
1answer
106 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
1answer
68 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 ...
2
votes
1answer
56 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
2answers
71 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
1answer
45 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
2answers
335 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
1answer
127 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
0answers
214 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
1answer
41 views

if FinalCompilationBooleanIsOn { use pst packages and input figures }

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
2answers
148 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: \...
5
votes
1answer
310 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
1answer
95 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
1answer
57 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
0answers
501 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 ...
16
votes
5answers
454 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
2answers
355 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
1answer
65 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
3answers
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 ...
6
votes
6answers
308 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}{...
6
votes
3answers
2k 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} ...
3
votes
1answer
326 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 ...
5
votes
1answer
303 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
1answer
494 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
2answers
242 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
2answers
181 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]{...
3
votes
3answers
577 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
1answer
194 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
2answers
77 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
2answers
360 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
1answer
301 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
1answer
186 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 ...
13
votes
2answers
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} \...
5
votes
1answer
560 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,...
5
votes
2answers
1k views

(x)ifthen in TikZ

I am searching for a way to conditionally handle some items in a TikZ \foreach specially using an \ifthenelse condition. However, the compiler responds ! Undefined control sequence. <argument> \...
6
votes
1answer
579 views

Is a page modulo 4?

If I want to test whether a page is odd/even (i.e. modulo 2) then I can use the following: \ifthenelse{\isodd{\thepage}}{}{} What can I do if I want to test whether a page is modulo 4? A minimal ...
8
votes
1answer
345 views

Compare the height of arguments

I'm trying to define a \newcommand with three arguments. I'd like to: compare the height of these arguments choose the largest height to create frames (with that height) around the arguments. ...
5
votes
2answers
793 views

How to select conditional text?

I've three variable statements : Statement1 = You are Great Student. Statement2 = You are average Student. Statement3 = You Need improvement on list of topics mentioned below. In the report ...
1
vote
0answers
29 views

Behavior of \global when used with xifthen package [duplicate]

I'm trying to calculate the sum of some numbers in my document. I want to allow non-integer values, so I'm using lengths, which works just fine. In my document it's often necessary to specify the ...
4
votes
2answers
738 views

Variable persist outside environment

I am using the ifthen package for some conditional formatting. I am storing state in some booleans, but it seems that there is an issue with lexical scope. In particular, when a boolean is set within ...
2
votes
1answer
391 views

Use result from pgfmath with xifthen

I try to use the results of pgfmath calculations with cnttest from xifthen, but it fails: \documentclass{article} \usepackage{pgf,xifthen} \begin{document} \pgfmathparse{42+77}% \def\val{\...
6
votes
2answers
651 views

Boolean based environments

I know that this question is basically identical to that of Hide custom environment content based on boolean Except I want to avoid using the environ package, which, otherwise, would be the best ...