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 [conditionals]

{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}.

0
votes
2answers
21 views

combining ifthen with FPeval - problem

if i use \FPeval{\one}{\csname test1\endcsname} everything is fine. If i use \FPeval{\one}{\csname test1\endcsname+\csname test2\endcsname} in \ifthenelse, then i get en error. \...
0
votes
0answers
18 views

Conditionally add options to tcolorbox highlight math style

I have defined the following package: % Configuration \NeedsTeXFormat{LaTeX2e}[1994/06/01] \ProvidesPackage{eqbox}[2018/01/01 Boxed Equations] \RequirePackage{xcolor} \RequirePackage{pgfopts} \...
1
vote
3answers
45 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
1answer
24 views

Problem with stored values, macro options, and interaction with other package

Apologies for the rather general title, while trying to sort out a very specific problem: I'm trying to enhance the framework that Alan Munn provided here to represent naturally occurring discourse (...
1
vote
1answer
41 views

Reset stored values at pagebreaks and environment boundaries

Based on this question, I have created a simple macro that prints and stores its argument, and if it is issued again with the identical argument it prints nothing: % !TEX TS-program = xelatexmk \...
1
vote
1answer
19 views

Embedding if statements in environments

I am trying to write an environment so that I can toggle on and off the answers to questions on a hand out. I also want the answers to appear red and then the main text go back to black after the ...
2
votes
1answer
40 views

Extra blank page is at end of the pdf when use vertical text using tikz

I need some text in the left and right side of the pdf vertically so I use the following code but an extra blank page appears and end please help. \documentclass[twoside]{article} \usepackage{lipsum} ...
2
votes
0answers
31 views

again about appendix to make hidden slides

I tried to put some slides in the appendix, but it doesn't work on my compiler. If I add an appendix after the first compilation it works, probably because the navigation bar is not yet updated, but ...
2
votes
1answer
38 views

How to make custom definition command without numbering?

I have the following \definition command/theorem (I don't really know much about LaTeX): \newtheoremstyle{definition} {0.8cm} {0.8cm} {} {0.4cm} {\bfseries} {.} {0.4cm} {} \...
2
votes
1answer
37 views

Exclamation mark around variable

What does the exclamation marks (!) around the \@subheader command do in the following? \renewcommand\maketitle{ ... \if!\@subheader!\else\noindent{\trfont{\@subheader}}\fi ... } Can someone please ...
3
votes
0answers
39 views

Using conditionals inside mcexam

I want to write exams where the questions and answers are randomized, and mcexam lets me do almost everything I want. However, I would also like each question to be picked randomly from a group of ...
2
votes
2answers
116 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 ...
1
vote
1answer
23 views

XeLaTeX + \ifthenelse:

I use XelaTeX to produce my CV. Currently, I want to update it and have both Slovak and English CV within one document. I want to have all strings of one language grouped in the preamble, same for ...
5
votes
1answer
121 views

How to compare a string to a cs from a read properly?

The scenario: reading a date in a yyyy-mm-dd form from a file to a cs. This cs later gets compared to a 'current date' macro to write a few args in a specific way to an external file. The current day ...
1
vote
1answer
24 views

How to write if else condition for vertical spacing in newenvironment

I have defined an environment as follows. I would like to have a modification where, it does not add white vertical space if no arguments are provided. \documentclass[10]{article} \usepackage[a4paper,...
1
vote
2answers
214 views

Transpose a matrix and parenthesis

I would like to define a command transp having eventually one argument : the name of the matrix and finally two outputs. \transp{A} is the matrix A^T between parenthesis, \transp A is just the ...
3
votes
1answer
49 views

How to properly use new options into \pgfdeclareshape of makeshape package

I'm tryng to make new shapes with the help of makeshape package, and I'm having a lot of problems with new options. Here, an example: \makeatletter \def\pgf@izquierda{izquierda} \def\...
5
votes
2answers
63 views

filecontents: select rows of group to display

I have a file that contains 1,000 rows of product data. I want to select only a specific product type to print in my document. Minimal code in main.tex: \documentclass{article} \usepackage{...
1
vote
0answers
38 views

What is the TeX at symbol / @ for? [duplicate]

Edit Note: I am trying to research "switches" (like \chapter), which led to this question. It might be helpful to tag this "switches". I have seen a lot of documentation that appears to be using ...
0
votes
2answers
48 views

Code seems to have no effect when inside `iftoggle`

In this answer I have been suggested to patch hyperref’s automatic pdfauthor metadata handling mechanism as follows. The goal is to have PDF metadata work with authblk and multiple authors. \...
2
votes
1answer
38 views

Conditional output dependent on --shell-escape option value

I would like to print the git revision of the document with the latexgit package, which requires the --shell-escape option to work. As this feature is very optional for building the document, I would ...
0
votes
0answers
29 views

Access to Testable Environment variables

I've figured out how to access environment variables, I can test on a value. I can't test on the value of an environment variable. I thought it best to include my test case: \documentclass{article} \...
4
votes
1answer
90 views

Is there latex3 work being done on a boolean case statement?

Various languages have constructs like select; when <expression 1> then <action 1>; when <expression 2> then <action 2>; ... when <expression n> ...
6
votes
1answer
123 views

How to save boolean values into the aux file? (using e.g. etoolbox's toogles)

I want to use etoolbox's toggles to achieve the following: In the preamble a toggle is created, during typesetting the document its value might change and at the end I want to write the value to the ...
4
votes
1answer
49 views

Auto append prefix to tcolorbox's title

I would like to have a tcolorbox environment that appends the prefix "Note:" to the given title. Thus, using the option title={My Title} to this environment would produce a title of Note: My ...
1
vote
2answers
52 views

Use of graphicspath in class

I am using my own class MyReportClass to write a report. I have taken inspiration from this answer to redefine the \includegraphics command inside the class in order to use the example-image-a in case ...
0
votes
0answers
23 views

Is it possible to make an “if” section in TeX which is conditional on an environment version being set?

I'd like to produce two slightly different versions of a document. One will include confidential information, the other will be slightly redacted. Is it possible to use an environment variable and ...
3
votes
0answers
105 views

Why do I get an “Incomplete \ifx” in this MWE?

I am trying to redefine the figure environment, which works fine in general. However, if the body of the figure environment to be replaced includes a tabular environment inside a conditional ...
1
vote
3answers
85 views

@nameuse with value \relax in conditionals

This is a follow-up to this question: @nameuse as conditional where i asked about how to use \expandafter if i combine \@nameuse with \ifx. However, in my real-life example, i use \relax as a default ...
4
votes
2answers
138 views

@nameuse as conditional

Please consider the following, non-working, example: \documentclass{standalone} \makeatletter \parindent\z@ \@namedef{blafasel}{foo} \def\foo{foo} \def\bar{bar} \makeatother \begin{document}...
4
votes
2answers
44 views

Defining a command part by part

Let's say we have a command \foo with 1 argument. Can we produce a command \setfoo{aaa}{<some thing>} which redefines \foo to: if an argument of \foois equal to 'aaa', do ; otherwise do what \...
0
votes
0answers
15 views

Conditionally print VC macros

How might I go about conditionally printing a macro? I know this exists for graphics (\includegraphics) and there's ifdraft for the rest. For example, using fancyhdr I have the following (simplified) ...
3
votes
1answer
68 views

Node label switching on condition

I try to create a dynamic graph where a node move along the axis line. When a condition on x is filled (X>1.8), I need the labels to be translated as i tried to do it in the following MWE \...
3
votes
1answer
61 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}} % {} % ...
0
votes
0answers
17 views

Translating a book: supporting both languages in a single project

I am currently translating a project from english to spanish. The project is organized by using subfiles. I want to move all .tex files to a 'en' folder, while creating a 'es' folder where I would ...
0
votes
0answers
26 views

In LaTeX is there good way to optionally redact certain sections of a document? [duplicate]

I have a project which compiles a document written in LaTeX, compiled to PDF with xelatex. I would like to automatically produce 2 versions of the document: A "confidential" version which all ...
4
votes
2answers
176 views

csvsimple vs. conditional row coloring

I've a CSV file what I want process with csvsimple. My desire is to color some rows based on a conditional (one specified column has bigger value). Here is an MWE: \documentclass[12pt]{article} \...
4
votes
1answer
140 views

How to add conditions in LATEX macros?

I would like to create custom macros with conditions. For example, I would like to add an "if-condition" to a macro that I created to write derivatives of any order in relation to a single variable. ...
2
votes
1answer
29 views

Question: Something's wrong--perhaps a missing \item

My code is as following: \begin{denotation} \iffalse \item[符号1] 解释1 \item[符号2] 解释2 \fi \end{denotation} I have \item in my code. What's the real problem?
1
vote
1answer
21 views

How do I only call \maketitle if \title{} has been called

I'm merging 5-10 pandoc generated tex files using the docmute package. The individual files build, however when I \subimport or \input them into my main document I get an error: ! LaTeX Error: No \...
0
votes
1answer
48 views

Change theorem color using theorem notes in the amsthm package

When defining a new theorem style in the amsthm package, you can specify what's called (according to http://web.mat.bham.ac.uk/R.W.Kaye/latex/thm.pdf) a custom head specification. In there, you can ...
0
votes
2answers
48 views

How to have “preprocessor” flags in LaTeX [duplicate]

C programmers often use constructs like #ifdef foo printf("foo is defined "); #endif #ifndef foo printf("foo is not defined "); #endif to select certain code-paths during the compilation ...
3
votes
2answers
19 views

Conditional within align environment not resolving

I try to use a shortcut for setting matrices with different brackets. My solution works fine in displaymath and equation environments. However, as soon as I try to use it within align, there is an ...
1
vote
1answer
20 views

Printing the bibliography conditionally by hooking \cite to toggle a boolean

I want to print the Bibliography slide only if there were any citations in the presentation. To that end I have redefined the \cite command to include the toggling of a boolean. I tried multiple ...
19
votes
5answers
1k views

Generating multiple versions of a document using options

Before I start, I want to say that I have already read this post and this post I am writing a paper in two languages. I want to write other language version of every paragraphs and title just below ...
1
vote
2answers
100 views

Conditional environment

In a huge document, I would like to use 'env1' or 'env2' environment depending on the value of a global variable 'flagenv'. How could I define an environment 'foo' so that I can write something like : ...
1
vote
1answer
53 views

Conditionals used in a new environment of detection of how many lines of quotation and with the selection of a language in XeLaTeX

I would like that a new environment of quotation/quote detect how many lines a text has, then will increase or decrease the quotation length/margin. For example: \newenvironment{citacao}[1]% {\...
1
vote
1answer
53 views

biblatex - custom citation with conditional clause

I have a custom footnote citation command defined by modifying this answer in the following way: \DeclareCiteCommand{\citejournal} % to get the journal entry ...
2
votes
1answer
58 views

Indentation of footnotes depending on number of digits in footnote marks on the same page

I wanted to adjust the left indentation of footnotes depending on the number of digits of the footnote mark. Thus, footnotes with one digit are aligned a the length of single \parindent (which is set ...
2
votes
1answer
55 views

How do I get permission for exam materials?

MWE \documentclass{minimal} \usepackage{ulem} book = 1 phone = 0 photocopy = 1 internet = 0 tablet = 1 \begin{document} Book, \xout{phone}, photocopy, \xout{internet}, tablet, \ldots\ free or open. ...