Skip to main content

All Questions

Tagged with
1 vote
2 answers
44 views

Can I change the effect of a command depending on the environment in which it's invoked?

I need a user-defined command to behave differently depending on whether it's invoked inside a \begin{quotation} environment or not. Is that possible? I don't know where to start!
digitig's user avatar
  • 125
0 votes
1 answer
57 views

Comparison of macros fails

I am new to LaTex and have been given a problem by my colleagues. They define a document type in a TeX file (e.g. 'svvr', 'srs', ...). This external definition corresponds to lines 4 and 5 in my ...
ruriger's user avatar
1 vote
2 answers
35 views

Weird Question with def, and condition

MWE: \documentclass{article} \def\ENLANG{english} \def\FRLANG{french} \def\LANG{\ENLANG} \begin{document} \if\LANG\ENLANG \ENLANG \else \FRLANG \fi \ifx\LANG\ENLANG \ENLANG \else \FRLANG \fi \LANG\ \...
Twilight's user avatar
1 vote
1 answer
63 views

Detect if a parameter passed to command is a mathematical formula

I'm defining a command which displays braced paragraphs and an isomorphism between them, but I want the command to recognize if one of the paragraphs is something purely mathematical and therefore not ...
Lorenzo Carozzo's user avatar
7 votes
4 answers
305 views

Adding up numbers

In a local class file I maintain, we have a system that can automatically add up numbers (in our case, marks for an assignment) and then output the sum. I would like to develop it to add up limited ...
rbrignall's user avatar
  • 1,574
1 vote
0 answers
32 views

How to make conditional command with non-numerical condition? [duplicate]

I would like to know if someone has a solution to the following problem: I have recently start to create shortcut to certain operator to display directly the parenthesis around their arguments. \...
Matsune's user avatar
  • 11
3 votes
4 answers
136 views

Compare first token after expanding macro once and discard the rest

How does one write an if clause that checks whether the first element of the immediate expansion is \mymacro, without fully expanding the input? \documentclass{minimal} \def\mymacro#1{Does something ...
Hyperplane's user avatar
1 vote
2 answers
71 views

How to do an if after an `exp:args` in expl3

Following this answer by @JasperHabicht, in my code, I would like to add an option to that macro so, depending on a flag I can execute either \drawMoveFromSgfCoords or \drawStoneFromSgfCoords. I still ...
psygo's user avatar
  • 438
5 votes
4 answers
482 views

Inline If-Else Statement Based on Macro Argument

How do I do an inline if-else statement? \draw[draw = #1, fill = \if black#1 white \else black \fi, line width = 0.1mm] (#2, #3) circle [radius = 0.25cm]; I've tried to do it based on this answer, ...
psygo's user avatar
  • 438
2 votes
3 answers
133 views

Conditional macros

Goal: I would like to have a macro that substitutes different commands depending in whether in displayed math mode or not. In particular, it should generate fixed-size angular brackets in text lines, \...
VKphysicist's user avatar
0 votes
1 answer
86 views

LaTeX: \equal not recognized within \section command

I have the following code, where I want to steer the language of some titles and some texts using a "\newcommand". The following minimal example uses the new command "kLanguage", ...
iGeeks's user avatar
  • 19
1 vote
1 answer
58 views

conditionals inside newcommand with multiple argument

This question is an extension of conditionals inside newcommand with empty argument I have a macro that looks like \newcommand{\pcs}[3]{{#1}_{#2}^{(#3)}} It is the third input where I would like to ...
Sayan's user avatar
  • 199
1 vote
1 answer
63 views

Add a plural sign depending on the number of items

I'd like to add a plural sign (say a 's') when needed. My current use case is for pluralizing a noun based on the number of pages in a document but I could also count oranges and bananas down the road....
green diod's user avatar
3 votes
1 answer
117 views

Help making conditionals in a macro

I have this bit of code that list the author in bold and each their affiliations in italics everytime \AddAuthor is called and send all authors to TOC. \newcommand{\AddAuthor}[2]{} %container \...
Andre's user avatar
  • 150
2 votes
1 answer
80 views

ifcase eats up letters

I created a command that switches between GCD and LCM. However it has a side effect of erasing everything before the second visible character after the command. How can I fix this bug? \documentclass{...
hau2643's user avatar
  • 21

15 30 50 per page
1
2 3 4 5
24