{conditionals} is about macros like \if and \ifx that may execute other macros depending on whether certain conditions are true or not. Popular packages are {etoolbox} and {ifthen}.

learn more… | top users | synonyms (1)

2
votes
2answers
52 views

Conditional preamble and pstricks problem \psTilt and \PstLightThreeDText

Look at the following MWE. \PassOptionsToPackage{export}{adjustbox} \documentclass{article} \usepackage{fancyvrb} \usepackage{graphicx} \usepackage{adjustbox} \newcounter{psextern} \makeatletter \...
5
votes
1answer
95 views

Selecting a subset of questions among a long TeX file

I have a big list of questions and solutions and I want to select a subset of them to use in exams. I am using documentclass exam. See the following example \documentclass[12pt]{exam} \begin{...
3
votes
1answer
58 views

Conditional evaluation of Sweave chunk

I'm using some R code to import and manipulate a time series. The code takes some minutes to run and, as a result, it generates a relatively small time series. Now, to prevent typesetting to take an ...
5
votes
0answers
18 views

How can I conditionally designate an active quote in csquotes.cfg?

How can I conditionally designate an active quote in csquotes.cfg so that no error is produced if the same character is made into an active quote in the .cfg and the document's preamble? I have the ...
4
votes
0answers
47 views

Problems in using the spreadtab and the ifthen packages

Using the spreadtab package for some computing, I have to write an expression (mixing of literal and numerical expressions) if some conditions are true. Using the ifthen package, all works well for a ...
4
votes
0answers
84 views

Checking environment in order to end it

I used to typeset verse with memoir package using some heavy \vspace trickery. The verse environment was too hard to control in terms of vertical space due to the immense amount of obscure glue. For ...
3
votes
0answers
42 views

Set draft depending on operating system

I'm working on two different operating systems - MacOS and Windows. While the main part of my work is done on OSX, I sometimes switch to windows for several reasons. Problem is: Windows and OSX don'...
3
votes
0answers
41 views

How can I efficiently create variants of a conditional?

Say I have the following: \prg_new_conditional:Nnn \sean_cond:n { T,F,TF } { \prg_return_false: } How can I efficiently create the following? (This list is arbitrary.) \sean_cond:nT \sean_cond:nF ...
3
votes
0answers
74 views

Insert or apply a decision structure to sequence or list

I would like to make the function calls \findLargest in the MWE below a little more dynamic and compact. As demonstrated in the example below, I can store glossaries values and include them in the ...
3
votes
0answers
126 views

\if and \fi inside different \def macros

Recently I failed to solve specific task in LaTeX. I wanted to make document with several sections, each divided on several subsections. Each section I had placed to separate files, and used \input ...
3
votes
0answers
96 views

how to add conditions inside itemize list?

List mentioned below is having three items. There are four variables : 1] varone 2] vartwo 3] varthree and 4] sub ; which are coming from external CSV file. Item 2 with "Value B" will be displayed if ...
2
votes
0answers
12 views

Combining \DTLgmeanforall with a conditional in a table created by datatool

I am organizing a list of students an there marks for exams in a .csv Document. These are printed in a tabular environment with the help of datatool. The Table lists the marks an the resulting mean. ...
2
votes
0answers
48 views

How do I let a float know on which column it is placed?

Is there a safe and sound way to let the insides of a float environment know on which column the float is placed? Here is an examples that fails: \documentclass[twocolumn]{article} \usepackage[...
2
votes
0answers
20 views

commands / package for target-group-specific creation of documents

Is there a package that allows me to create target-group-specific documents. Basically I have two scenarios: There is an exercise document and each task is initially followed by a solution. In that ...
2
votes
0answers
26 views

How do I extend if logic from skipping particular slides to specific portions of a Beamer frame?

I have the following working structure for excluding particular lecture slides from the article form of a lecture: \documentclass[11pt,handout]{beamer} \newif\iflecture \lecturetrue % Next three ...
2
votes
0answers
32 views

How to only print endnote section if there are any endnotes?

I am using the enotez package and would like to be able to call \printendnotes regardless of if there are actually any endnotes. In the case that there are no endnotes I would either like the \...
2
votes
0answers
21 views

Automatically Detect When in an Mdframed frame title

I would like to be able to detect when I am within a frametitle={} of an mdframed environment. One way is to manually set a flag within the \frametitle={}, but wondering if there is some other way to ...
2
votes
0answers
59 views

“Draft” mode for document

Suppose you want to keep two versions of the same document: one where you highlight changes and one where you show the final result. How can I use a "debug" or "test" mode to turn on/off my \textbf ...
2
votes
0answers
59 views

Access xparse's \BooleanTrue via latex3 expl3

I'm implementing a command with xparse's boolean token processing \NewDocumentCommand{\op}{s o t' t. t^ g}{ % Here I need to check for % (#3 || #4 || #5) && !(#3 && #4 &...
2
votes
0answers
56 views

\ifbeamer@anotherslide and \ifbeamer@localanotherslide in beamerbasedecode.sty

At the beginning of the source file beamerbasedecode.sty of beamer class, two switches are defined: \newif\ifbeamer@anotherslide \newif\ifbeamer@localanotherslide By reading beamerbasedecode.sty ...
2
votes
0answers
224 views

Constraint for a decoration: how to know result after decoration

My question is kind of extending of this answer. I want to decorate a path with text only when text fit the path, but also I want to know if decoration was success. I need to know this to be able to ...
2
votes
0answers
300 views

Why can't I get a conditional command to work in a macro invoked within a tikzpicture?

I wanted to create a macro that can be invoked in the middle of a tikz path and behave differently, conditional on one of the arguments. Here is an example document: \documentclass[a4paper]{amsart} ...
2
votes
0answers
299 views

Knitr/LaTeX: conditional execution based on external parameters

I'm using knitr to create LaTeX documents with integrated R code. Now I'd like to readout some external parameters (saved in a TXT or CSV file) and create a document based on the conditions specified ...
1
vote
0answers
30 views

Conditional pagebreak depending on position on page

Is there a way to say, add a newline here, if there are less than x empty lines before the next assumed pagebreak? something like \newpageIfThisLineIsLinesAwayFromBottomLessThan{5} I know that this ...
1
vote
0answers
67 views

A method of distinguishing Iverson from other brackets?

Is there a common idiom or method for distinguishing Iverson brackets from "normal" brackets? In all examples I've seen, simple braces [...] are used for both; but in complex expressions, this can ...
1
vote
0answers
39 views

Passing optional arguments to a listing environment based on conditionals

I am trying to make a presentation which can optionally compiled for handouts. This presentation also contains highlighted code snippets. For highlighting I use the code from this question. (Which ...
1
vote
0answers
100 views

Ending a tikzpicture environment in conditional causes “Missing } inserted”

I want to create a number of tikzpictures. I have a number of items I want to draw. Each tikzpicture takes up a whole page and may contain up to 4 items. (It is not good enough to to have each item in ...
1
vote
0answers
137 views

Conditional spacing based on length of chapter title

In LaTeX, (or possibly XeLaTeX), how can one achieve the following: A double spacing a 1- or 2-line chapter title, and single spacing under a 3- or more-line chapter title. A triple space ...
1
vote
0answers
45 views

Creating multiple output files, with content that depends on a variable

I'd like to write a template for a letter, which is meant to be sent to many people. Thus, the content should change slightly depending on who is the addressee. For instance, I imagine that the ...
1
vote
0answers
69 views

Special conditionals (TeX)

Is there a way to compare strings rather than single tokens? Is there a way to check if a parameter in a command is a string or a single character? If there is either, how do I?
1
vote
0answers
68 views

Indicating that the adjustwidth environment should be placed around text

I've been trying to work out a solution to this question about changing margins for body text without changing header/footer placement. Using the changepage package, I was able to work out the ...
0
votes
0answers
25 views

tex4ht \ifdefined\HCode equivalent for Latex2rtf

One of my favorite features of tex4ht is that I can customize formatting or content depending on what compiler is being used by enclosing code in an if statement that is capable of providing a flag ...
0
votes
0answers
43 views

csvreader: conditional formating of negative numbers

I have a csv file that contains both strings and numbers, and am using csvsimple to print it in my pdf. For those numbers that are negative, I'd like to print them in red For the positives one, I'd ...
0
votes
0answers
28 views

how to define a general conditional for a complete text

I wonder how to define a newcommand of the type with general conditionnal \def\a{} which givefor each call in the text %\begin{comment} %\end{comment} when a=0 and \begin{comment} \end{...
0
votes
0answers
40 views

Conditional compilation with tags to allow flexible output

For various beamer slides I'd like to be able specify more granular on what slides to include and what slides to omit in my compilation. I'd like to specify multiple tags for each slide and I'd like ...
0
votes
0answers
62 views

How to change margins based on paper size?

My document uses US letter: \ProcessOptions\LoadClass[letterpaper,twoside]{report}, with the following margins setup: \geometry{tmargin=25mm, bmargin=25mm}. Now, if I change the paper size option ...
0
votes
0answers
66 views

Conditionally prepend text to chapter title in TOC

I want to prepend some text to chapter titles on the TOC according to certain conditions. For example (this doesn't work): \documentclass[letterpaper,openany,oneside]{book} \usepackage[spanish]{babel}...
0
votes
0answers
57 views

Output two files

I'm tiring of maintaining two different CV and resume .tex files and want to combine them into a single file. I'm considering etoolbox as a way of combining my CV and resume into the same. Then I ...
0
votes
0answers
96 views

How do I add multiple macro definition inside an \ifbool compound statement?

What follows is my example doofus.sty: \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{doofus}% [2014/01/01 v0.01a LaTeX doofus package]%\filedate\space\fileversion\space \typeout{Package doofus, \csname ...