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

Filter by
Sorted by
Tagged with
1
vote
0answers
40 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
51 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
40 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
48 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
136 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
34 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
131 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
25 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
255 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
56 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
72 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
43 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
50 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
54 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
31 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
95 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
128 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
54 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
96 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
28 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
128 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
100 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 ...
3
votes
2answers
141 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}...
3
votes
2answers
45 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
24 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
76 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
67 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
19 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
27 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
230 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
168 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
45 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
25 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
51 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
69 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 ...
4
votes
2answers
22 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 ...
2
votes
1answer
29 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 ...
18
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
126 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
58 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
55 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
66 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 ...
1
vote
1answer
56 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. ...
6
votes
1answer
68 views

How to compare number from \newenvironment argument

I am trying to create a new environment as follows \newenvironment{letters}[1]{% \vspace{-3mm} \ifnum #1=1% \else \begin{multicols}{#1} \fi \begin{enumerate}[label=\textbf{...
2
votes
1answer
46 views

How to test a \newif conditional in expl3

Suppose I want to test an \ifSomething conditional that is defined by a package which may or may not be loaded. I know how to do this in plain LaTeX, but I'd like to define an expl3 conditional to do ...
4
votes
1answer
370 views

How to use true/false inside definitions?

Suppose you want to define page style depending on a boolean value. I think both constructions below have equivalent output (or not?), but which is better/more indicated/professional/elegant? \if@...
4
votes
2answers
155 views

Tikz `\ifeven` triggering error

Why the following sample fails to compile in pdflatex when \ifeven is used? It fails with many errors in line 34 (where the last closing brackets are). The errors are like: Undefined control sequence....
2
votes
1answer
71 views

How to break a line inside a table cell and add text in the next column ONLY IN CERTAIN CASES?

I am quite new to LaTeX and I am making a wine menu. In some cases I need to add a price for a single glass and/or for a half-carafe... But ONLY in these cases, when such an option exists. I found ...
4
votes
2answers
151 views

Conditional Styling latex on items

I am trying to create an agenda (headlines) frame for my presentation slides. I am reducing redundancy, and define the itemized frame once, and reuse it. But each time, i want a different item in the ...
1
vote
1answer
35 views

How do I insert text in the main body conditional on whether or not a label is defined

I have a set of documents I work with, where I include various files to complete them. So the main document might appear: \section{Section A} \input{SectionText1} \input{SectionText2} \section{...