{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)

6
votes
1answer
246 views

Compare numbers with comma as decimal points

I want to check whether a number \a (read from a file) is smaller than zero using ifthenelse: \ifthenelse{\a<5}{smaller}{not smaller} This works fine when a is in the format -1. In the file ...
8
votes
1answer
178 views

Is there a macro telling which OS we're using?

I got some LaTeX documents that I have to compile them under different TeX Live, such as MacTeX or TeX Live. But in different OS, the font seems different too, for example, while in Windows, I prefer ...
5
votes
1answer
158 views

Automatic assignment of references to bibliography categories depending on origdate or date

I'm using biblatex-chicago with the author-date option. I love biblatex and biblatex-chicago and appreciate the work that has been put into it. I have a small question, however. I usually divide my ...
6
votes
1answer
91 views

How can I test if a label has been marked?

I have a long document which includes several files. In some cases I may want to include those files in different orders. In some cases, I may want to adapt the text depending on whether a specific ...
11
votes
3answers
384 views

How to ensure document total page numbers is a multiple of four?

I'm producing a document (book class) that will ultimately be produced using offset lithography. It's therefore useful to ensure the total number of pages is a multiple of four by adding as many blank ...
3
votes
1answer
81 views

Use alternate cite keys depending on document version

My biggest enemy is the page limit. I use short versions of my BibTeX entries in order to keep the list of references short. I now have a situation where I include the file in the journal article and ...
13
votes
2answers
169 views

Load different options depending on package version

Is there any possibility to load a package with different options depending on the version of the package? The command \@ifpackagelater{package}{date}{true}{false} only works if the package is ...
10
votes
1answer
215 views

querying whether a font feature has been activated via a fontspec command

A LaTeX package I'm currently writing makes use of -- and definitely requires -- some of the power of LuaLaTeX. I would like to make my package's user interface -- in particular, the options that need ...
1
vote
1answer
269 views

Change marginpar for each page

I want to be able to change the marginpar and right values for each page, depending if the page has notes or not. MWE: \documentclass{article} \usepackage[top=3cm, bottom=3cm, left=3cm, right=8cm, ...
7
votes
2answers
134 views

biblatex: test whether a command is inside a cite command

The idea is the following: Normally, \fullcite just prints the full bibliography entry by calling \usedriver. In my style biblatex-fiwi I added the option to suppress stuff like foreword and ...
5
votes
1answer
66 views

Testing for commercial at (@) in a string [duplicate]

Possible Duplicate: Changing catcode for commercial at (@) inside a macro to get it matched in pattern. I want to test whether a string contains the @ sign. I came up with the following ...
4
votes
1answer
613 views

Defining a prose-style section break command [duplicate]

Possible Duplicate: Paragraph breaks with asterisks I'm trying to define a command to insert section breaks into a prose manuscript. Specifically, I would like to use a command to insert ...
1
vote
1answer
132 views

Conditionally generate word explanations in appendix

Is there a way to declare a set of conceptual keywords with their explanation that will be taken and compiled into the appendix when one of the keywords is used throughout the documents body? For ...
4
votes
1answer
308 views

etoolbox's iftoggle vs verbatim

My problem is that I can set up toggles, using etoolbox's \newtoggle{x}, set it to true with \toggletrue{x} and even use it with iftoggle{x}{this for true}{this for false}. However, if I try to put a ...
4
votes
2answers
102 views

How to test if a given reference belongs to a list of labels?

This question is a prolongation of my previous question How to choose from a list for using result in \ref?. I got really good and interesting answers. Unfortunately I can not implement them for my ...
2
votes
1answer
78 views

Variable number of column in multicols, including a single one [closed]

I'd like to call multicols with a parameter being the number of column and allow this parameter to take the value 1, like in this minimal working example : \documentclass[a4paper,10pt]{report} ...
2
votes
0answers
76 views

Check if compiled using MiKTeX or TeX Live? [duplicate]

Possible Duplicate: Is there a way to detect from inside a package that MikTeX is used? We have multiple people writing on the same project. Since some of us are TeX Livers and other ...
8
votes
3answers
189 views

How to postpone the set up of a conditional?

I'm about to produce a series of assessment texts. Some of these assessments have annexes, others don't. I would like to be able to define a specific class, like this : \documentclass{myexam} ...
12
votes
1answer
433 views

Biblatex: Print ISBN only if DOI is not defined

I have a large set of references and I in most cases do have either ISBN DOI DOI and ISBN I'd like to setup a filter that prints the ISBN only when the DOI does not exist. How can I set up a ...
6
votes
2answers
126 views

ifx and pdflastypos

I'm not fully grasping how the \ifx command handles types. How should the following def's read to make the \ifx statement true when pdflastypos is at the zero coordinate? \def\nothingness{0} ...
5
votes
2answers
332 views

biblatex conditional for printing an extradate

This is a follow-up question to biblatex format for online sources. I have the following biblatex configuration file. Thanks to Guido for the inputs. I have also taken some code for the ...
4
votes
1answer
166 views

How to make tabularx columns using \whiledo?

My question is similar to that discussed in How to programmatically make tabular rows using `\whiledo` ?. The difference is that I want to produce columns rather than rows with using \whiledo. ...
1
vote
0answers
40 views

Hidden environment [duplicate]

Possible Duplicate: Suppressing remarks when not needed Is there a way that I can define a new environment in my manuscript which will only be typeset when a flag is activated? Otherwise ...
0
votes
1answer
359 views

Pass multiple options to \newcommand

I have defined a new command for each of the team members in my project group to add individual todo-notes with different color and name. Now I would like to add another option, but is having trouble ...
4
votes
1answer
465 views

variable for color in latex

I am using beamer for writing my presentation. I was initially using latex+dvipdf, then with the help of other tex.exchange users I recognized that I cannot use transparency in this way. So now I am ...
9
votes
2answers
217 views

\ifpdf returns true when using LuaLaTeX

The ifpdf package is supposed to detect if pdfTeX is running: This package looks for pdfTeX in pdf mode and implements and sets the switch \ifpdf. (from the ifpdf documentation) However, when I ...
6
votes
1answer
76 views

How to create a conditional which checks the value of written text in plain TeX?

I need to create a conditional in plain TeX like this: IF #1 = "N" THEN PRINT "TRUE" ELSE PRINT "#1" I tried various ways in TeX. The solution must be simple, but none of the ways I tried ...
8
votes
4answers
532 views

How to create a conditional which checks if one or another condition is true in plain TeX?

I need to make a conditional like this: IF #1 > \variable OR #1 = 0 THEN PRINT "True" ELSE PRINT "False" If #1 is greater than \variable or is equal to 0, then it it true. The value only ...
7
votes
3answers
9k views

How to avoid empty 'thebibliography' environment (bibtex) if there are no references?

I have a general and central preamble for a lot of similar-style documents (several dozens) and most of the documents have a Bibliography at the beginning, so I call \bibliographystyle{alphadin} ...
1
vote
1answer
134 views

Insert a figure on odd pages

I would like to insert a logo on each odd pages of my document (but the first) I know how to do it for each page but cannot figure out how to only do it on odd pages. So I have \makeatletter ...
8
votes
2answers
102 views

Creating an error message

Is there a way to create my own error message that is given if the main font size isn't set to 11pt and then the compilation of the document begin stopped? Update I'm trying to write a package, ...
17
votes
1answer
213 views

Is there a right way to do combined conditionals in LaTeX3?

I have some LaTeX3 code and I want to add a new feature. This will involve choosing between various actions at a particular point. There are two choices to be made, and these choices are ...
0
votes
0answers
31 views

conditional usepackage given documentclass [duplicate]

Possible Duplicate: Which document class is being used? How would I conditionally usepackage{enumitem} if the document class is memoir (but not beamer)? Could I use the etoolbox ...
3
votes
2answers
448 views

ifthenelse conditional & macro

Why I get the error below if I use the \ifthenelse{\boolean{@parts}}% {% }{} conditional (defined into classicthesis.sty) you try to comment it, you don't have any error? ...
3
votes
1answer
174 views

Check if non-empty subsection exists under another section

I'd like to try to make a LaTeX class which enforces a number of (non-empty) sections to exist-- if the user doesn't define them manually, then some default section content will be created. ...
7
votes
1answer
101 views

ifoddpage not working

I'm testing ifoddpage but it seems to say that every page is even: \documentclass{article} \usepackage{lipsum} \usepackage{ifoddpage} \newcommand\printpage{% Page is \thepage. It is \ifoddpage ...
7
votes
2answers
238 views

How do I check if a biblatex entry contains an author field?

I'm writing a paper on a very large number of pieces of artwork, and I've been trying to automate the creation of my section headings, but I've run into a roadblock when I try to check if a Biblatex ...
5
votes
2answers
274 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 ...
4
votes
0answers
89 views

Where‎ ‎do‎ I start ‎learning‎ conditional tests ‎in ‎LaTeX‎?‎ [duplicate]

Possible Duplicate: LaTeX conditional expression I've already taken a look at ‎books‎ such as "‎Te‎X for the Impatient", but its examples aren't clear enough to me. What‎ book/tutorial ‎do‎ ...
2
votes
0answers
70 views

Conditional coloring in LaTeX [duplicate]

Possible Duplicate: Parametrize shading in table through TikZ Is there any package that provide conditional coloring in LaTeX ? I would like to reproduce what Excel does with its ...
3
votes
1answer
145 views

Defining macros based on environment

Right now, I have two macros, \intersects and \union, that simply point back to \cap and \cup respectively. Unfortunately, to have nice typesetting in display-like environments, I need to use \bigcap ...
6
votes
1answer
108 views

Package providing fully expandable conditionals

Is there a package providing a collection of fully expandable conditionals like this one: \newcommand\myif@num[1] {\ifnum#1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} Background: ...
1
vote
3answers
545 views

ifpackageloaded question

why when i comment \usepackage{geometry} i get error? \documentclass{book} \usepackage{geometry} \makeatletter \@ifpackageloaded{geometry} { % i the package was ...
4
votes
2answers
115 views

A dangerous \if@ in the dtx preamble

Why does the following .dtx not compile, while the equivalent .tex file does? (You must name the file error.dtx, that's what \DocInput includes.) DTX: % \iffalse meta-comment %<*driver> ...
6
votes
2answers
269 views

How to extend a macro for e-mail addresses to support multiple arguments?

I prepared the following macros to format e-mail adresses in a e-mail header. \usepackage{xifthen}% Provides \ifthenelse and \isempty % E-Mail header strings with format. ...
2
votes
2answers
168 views

Reference Page of Float Object only if Page isn't actual page

Is it possible to tell LaTeX only use \pageref if the referenced object isn't on actual page? if \pageref{fig:hello_world} != self.page then \pageref{fig:hello_world} end
3
votes
2answers
288 views

\jobname in Gummi

The command \jobname usually print the file name without the path and extension, so inside a file called foo.tex will print just foo. With pdflatex foo.test or compiling from LaTeXila certainly I ...
17
votes
1answer
559 views

How does TeX handle \else and \fi in conditionals?

I have seen packages using \def\afterelse#1\else#2\fi{\fi#1} which TeX seems happy to accept. But on taking the first branch, isn't TeX expecting \else instead of \fi? That is, isn't the following ...
6
votes
2answers
427 views

Nesting of test commands (IfStrEq, IfSubStr etc.) of xstring

The following code does not work: \documentclass{article} \usepackage{xstring} \newcommand\checkempty[1]{ \IfStrEq{#1}{}{% Empty }{% NonEmpty } } \begin{document} ...
8
votes
1answer
287 views

How to create conditionals in a document class for latex?

I am trying to write a document class highschool.cls for the high school research papers in our school based on the book.cls in order to make the format of the papers standardized. I am trying to ...