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

1
vote
0answers
56 views

Only input file if it exists [duplicate]

Possible Duplicate: Expandable version of \InputIfFileExists or \IfFileExists I am writing a LaTeX file where I input other LaTeX files (if and only if its exits, otherwise it should not ...
13
votes
3answers
427 views

Making a “For Loop”

I am trying to make a "for loop" that will iterate the variable reaches 1. However, none of the "for loops" I have found in the Internet works. These files will be distributed to other people and ...
10
votes
3answers
193 views

Using \@ifnextchar to define a macro for “ante meridiem” time

I want to create a macro for times of days, as follows: \newcommand{\pmtime}{a.m.\xspace} The problem is that LaTeX thinks that the last period in a.m. denotes the end of a sentence, hence the ...
6
votes
1answer
239 views

Footer Suppression

I'm wondering if it's possible to suppress footers if the page has a footnote, but display the footer as normal otherwise. To be specific, I'm reproducing an old book which uses catchwords for pages ...
7
votes
1answer
113 views

Can I detect whether my macro is being used inside a subscript or superscript?

I defined this macro: \newcommand{\foldeq}[1]{\sim_{#1}} Later on, I noticed that when it's used inside a subscript, it looks a little bit hard to tell whether it's $\sim f$ or $\sim_f$. ($\sim f$ ...
7
votes
4answers
829 views

Logical String Length

How do I do a conditional 'if then else' statement, based on length of string being greater than (or less than, or equal) a specified value. For example, something Like \def\mystring{XYZ} ...
10
votes
3answers
182 views

\expandafter and counters not playing nicely

My google-fu has finally failed me... I'm trying to write a package that will allow you say \addauthor{name, email} several times and have the title page properly formatted. Here is a minimal example ...
6
votes
1answer
615 views

What is wrong with the following latex code? [closed]

I have written this code to formulate the algorithm for merging two arrays, but I get an error. \begin{algorithm}[t] \caption{Serial Merge} \label{alg:insert} \begin{algorithmic}[1] \Require Two ...
16
votes
3answers
2k views

Includegraphics maximum width

With \includegraphics I can give the width of the resulting image (which would be scaled). How can I give a maximum width of the image? That is, if the original is smaller than X, I'd like to keep ...
8
votes
1answer
131 views

Compare \CurrentOption with a string

I encountered a problem that I want to compare the \CurrentOption with a string. In the .tex file I have a code below. \usepackage[en-ver]{cufestatletter} Then I want to use \ifx to determine ...
2
votes
1answer
77 views

Section outside multicols environment if section contains a table

I am using \begin{multicols*}{2} to split my text in two columns on the landscape format paper. Now if I have a tabular, it resizes the tabular to \linewidth. What I want is to ask if there is a ...
6
votes
1answer
282 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
191 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
171 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
411 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
175 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
218 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
289 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
140 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
697 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
149 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
377 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
108 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
81 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
77 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
191 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
457 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
129 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
380 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
204 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
42 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
427 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
525 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
245 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
78 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
721 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 ...
8
votes
3answers
12k 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
153 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 ...
9
votes
2answers
109 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
216 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
511 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
195 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
119 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
264 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
301 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
92 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‎ ...