Skip to main content

Questions tagged [robust-commands]

Filter by
Sorted by
Tagged with
0 votes
1 answer
57 views

Add a hook to the argument of a command based on its other arguments [closed]

Take \textcolor{#3}{#4} as a simple example. However, the actual command contains asterisked and optional arguments. If the argument #3 is green or blue, then \textcolor{#3}{#4} should produce ...
Inverted Pastry's user avatar
2 votes
1 answer
45 views

Nested custom commands not working

I have defined the following commands for my latex document: \newcommand{\uat}[2]{\ifthenelse{\equal{#2}{}}{\boldsymbol{u}_{#1}}{\boldsymbol{u}_{#1}(#2)}} \newcommand{\opt}[1]{\ifthenelse{\equal{#1}{}}...
Trb2's user avatar
  • 123
3 votes
1 answer
297 views

How to create a custom command (control sequence) with special characters in its name

I want to create a custom command (control sequence) whose name contains special characters (such as numbers, underscores _, or -). In order to better distinguish different commands, my code is as ...
Tommk's user avatar
  • 31
5 votes
4 answers
527 views

Make a command robust (unbreakable)

If you define \bletter with \DeclareRobustCommand\bletter[1]{\textbf{#1}} it works fine even within section commands. But if you want to use it in an \edef or \xdef command, \bletter will be broken (...
user300467's user avatar
7 votes
1 answer
200 views

What command should supersede \DeclareRobustCommand?

In section 6.1 of clsguide.pdf (link: https://www.ctan.org/pkg/clsguide), under "Commands superseded for new material", the class guide lists the command \DeclareRobustCommand and \...
User23456234's user avatar
  • 1,900
1 vote
1 answer
60 views

How to achive that subscripts/superscripts are scaled with the font size in a robust command?

I would like to use smaller fonts for the subscripts and superscripts in a user-defined LaTeX command. Do you have any ideas how to scale down the subscripts/superscripts proportionally? My MWE is the ...
TobiR's user avatar
  • 614
13 votes
3 answers
865 views

\NewDocumentCommand vs \newcommand vs \NewExpandableDocumentCommand (to define a container for a text)

In his answer to a recent question of mine, @egreg advised \newcommand instead of \NewDocumentCommand to define a container for a text. And I'm aware of this (10 years old!) question where: Joseph ...
Denis Bitouzé's user avatar
1 vote
2 answers
161 views

How to make a new command that accepts math parameters?

So I have been trying to make a command to display my very particular notation for restriction, but I believe parts of it involve text commands and other parts involve math commands, I thought I had ...
Felipe Dilho's user avatar
1 vote
1 answer
66 views

How to make \mathbf robust?

I made a command \statementinput which makes a table easily with given two lists of elements. Most of the elements are math formulas, and I don't want to put each of them in \(\), so I used the array ...
Jaehyeon Seo's user avatar
1 vote
1 answer
141 views

Use `\(...\)` in `algpseudocode`

Is there a way to use the newer \(...\) math syntax in arguments for any commands from algpseudocode (algorithmicx)? The documentation and virtually any other tutorial uses the TeX-primitive $...$. ...
Gargantuar's user avatar
  • 1,251
1 vote
1 answer
39 views

\subfile expands robust commands (so differs from \input in that respect)

I'm overloading _ as a non-breakable dash in nonmath, and this poses no problem with \input: \documentclass{article} \usepackage{babel} \let\subscr=_ \catcode`_=\active \DeclareRobustCommand_{\ifmmode\...
Michaël's user avatar
  • 1,474
2 votes
1 answer
97 views

Halloweenmath package collides with hyperref

Recently I am making some handouts, and I want to use the halloweenmath package in my handouts. Problems occur when I tag some equation with symbols in the package (e.g. \mathwitch and the like) and ...
DML's user avatar
  • 25
0 votes
0 answers
22 views

Correctly redefine \eqref to allow post- and pre- text

From amsmath.dtx, the original definition is: \DeclareRobustCommand{\eqref}[1]{\textup{\tagform@{\ref{#1}}}} I would like to redefine it so as to have post- and pre- text in the parentheses. My ...
Jinwen's user avatar
  • 8,720
5 votes
2 answers
682 views

Why is there no \ProvideCommandCopy?

When we look at xparse package documentation there are four related commands \NewDocumentCommand \RenewDocumentCommand \ProvideDocumentCommand \DeclareDocumentCommand Similarly there are four ...
nim's user avatar
  • 345
4 votes
1 answer
55 views

package ntheorem seems not to obey the LaTeX-kernel's old protection mechanism

This question is related to my answer to the question Construct math super/sub-script from reference (\ref) with hyperref and cleveref being loaded: [...] In the example below this is done via ...
Ulrich Diez's user avatar
  • 30.1k
0 votes
1 answer
20 views

Why a space make failed the evaluation of a command in \bibliography

I created a command containing a list of bib files separated by a comma and a space. Then, I give this command to \bibliography, which produce no bibliography. If I create the same list but only ...
R. N's user avatar
  • 1,162
0 votes
0 answers
58 views

Code Listing in second Index using imakeidx and macros

I am writing a LaTeX document containing Python code, which I include using the Listings package through a macro called \example{}. It uses another macro called \code{} that also uses the Listings ...
AstroFloyd's user avatar
5 votes
3 answers
594 views

Remove extra space generated by a LaTeX command

My LaTeX document contains the following lines: \documentclass{article} \usepackage{etoolbox} \newcommand{\defineSpecies}[2]{\csdef{spec@#1}{#2}} \newrobustcmd{\spec}[1]{% \ifcsname spec@#1\...
TobiR's user avatar
  • 614
0 votes
1 answer
125 views

Configuring custom command for quotes in book class

I am trying to configure and optimize my custom quote commands. I like to set it in a way that it will take the quoted text as the mandatory argument and the quote-author and source/description as two ...
raf's user avatar
  • 849
3 votes
1 answer
92 views

Call a newcommand (or robust command) within \label

I would like to pass a newcommand to \label. Could you please help me how to do this? My (uncompilable) MWE is the following: \documentclass{article} \usepackage{longtable} \DeclareRobustCommand{\...
TobiR's user avatar
  • 614
5 votes
1 answer
478 views

Is it still necessary/useful to execute \robustify\(?

I know that etoolbox provides a robustify command and I've been executing \robustify\( in my headers forever now. But, answers like this one also suggest loading fix fixltx2e to make it robust. ...
Peter Gerdes's user avatar
9 votes
3 answers
966 views

Fibonacci macro

I am trying to make a Fibonacci macro, that works as follows. I was able to do so, and I tried to make everything private by using @ (i know it isn't necessary here, but I am trying to practice...). ...
needle's user avatar
  • 913
7 votes
8 answers
3k views

Ackermann Function

I am trying to write a macro to evaluate the result of the Ackermann function. If anyone doesn't know it, is defined as follows: So I am trying to write a code that is able to compute it but I can't ...
needle's user avatar
  • 913
3 votes
2 answers
62 views

tex4ht using \(...\) in moving arguments

I'm using tex4ht to produce HTML that contains mathematical content to be rendered using MathJax. This question is about inline mathematical content in moving arguments, such as \section{\(y^2\)} and \...
cmhughes's user avatar
  • 102k
4 votes
2 answers
278 views

Robust command not expanding as \input argument

I could really use some help - I've been using LaTeX casually for several years, but have rarely had to dive into the details or problems, and I can't figure this out. Problem I am working with a .cls ...
Adam Kern's user avatar
  • 143
0 votes
1 answer
52 views

Creating multi-line indent with hangparas

I'm trying to have all the text in a theorem or definition indented as it is usually done in books, however the hangparas environment just doesn't work for me and I have no idea why. Here is the ...
nDARQ's user avatar
  • 3
1 vote
1 answer
394 views

Auto label inside a new command definition for easing the usage of hyperref

I am trying to build a controlled dictionary. I used a template where it's defined a command to insert a new entry. I would like to assign a label to each entry so that I can link similar terms with ...
G M's user avatar
  • 2,265
3 votes
2 answers
177 views

latex command for undetermined number of parameters

I am trying to use a smart way to typeset some diagrams as these single stranded diagrams. But I would like to do two more things, one is to allow n of them to be stacked together as and be able to ...
wooohooo's user avatar
  • 247
2 votes
2 answers
210 views

Safe way of redefining \- only for math mode

I know that \- is already used for hyphenation and inside tabbing. How can I patch this command such that it does something else, but only inside math environments? I tried the following: \...
Hyperplane's user avatar
0 votes
1 answer
101 views

Using tikzpicture as robust command within section title

I was trying to use a tikzpicture using a robust custom command in a section title as is it described here. I'm not getting error when using the robust command but my custom symbols definition is ...
yummigummi's user avatar
0 votes
0 answers
96 views

Why the * in \newcommand*? [duplicate]

I saw several examples of user defined macros using \newcommand (without the *), and examples with \newcommand*. Trying both in my test documents doesn't show any difference. So why the asterisk? ...
Cham's user avatar
  • 2,338
2 votes
1 answer
500 views

Change command in package

Im trying to use the venndiagram package but i want to change the colour it fills in the areas. Currently if you use the code for example \begin{venndiagram2sets} \fillOnlyA \fillNotAorB \fillA \end{...
Jettie Baker's user avatar
1 vote
0 answers
256 views

Redefining `\global\long\def` to always use `\robustify`

I use LyX and the math macros are compiled to LaTeX using \global\long\def\mymacro#1#2{body} (for a binary macro). This leads to me having to \robustify many of those macros. I tried redefining \def ...
xavierm02's user avatar
  • 787
3 votes
1 answer
81 views

Can quotes made with \MakeAutoQuote made robust in a \ulem?

The following example gives the error ! Extra }, or forgotten \endgroup because of the »« in the \uwave command. Can the definition of the quotes be changed to avoid the error without loosing the ...
Ulrike Fischer's user avatar
1 vote
1 answer
496 views

How to include paragraph break in command argument?

Here is my MWE: \documentclass{article} \setlength{\parindent}{0pt} \setlength{\parskip}{3pt} \begin{document} Here is the first paragraph. Here is the second. \newcommand*{\testing}[1]{#1} \...
me--'s user avatar
  • 377
2 votes
1 answer
419 views

Create a list through commands

Is there a way I could do something like \createlist{listone} % A description list specifically \additem{listone}{item1}{description1} \additem{listone}{item2}{description2} . . . \makelist{...
M.O.'s user avatar
  • 316
4 votes
2 answers
107 views

How to extend the elements package to print melting and boiling points?

To my propose I would like to extend the elements package to print too the melting and boiling points of chemical elements. Using the same logic used in elements package, I thought about creating ...
grsousajunior's user avatar
0 votes
0 answers
374 views

Removing commands from input to command

I'm trying to create my own command to highlight some changes. I want the command to update a counter, add a line in the contents table and do some changes in the text. So far, I got: \...
Ger's user avatar
  • 187
2 votes
0 answers
187 views

Help Understanding/Adapting the Definition of Beamer's 'lecture' Command

Beamer's 'lecture' command has been a great way for me to have all my lecture notes in one document, but typeset only the segments that I need for any given day/week of class. Ultimately I would like ...
stevo1977's user avatar
0 votes
1 answer
172 views

Robust command for tikz yshift

I created a robust command declared in preamble to include a small figure in the text. \DeclareRobustCommand\mytikzcell{\tikz \tikzset{b2block/.style = {rectangle split, rectangle split parts=1, ...
karmanaut's user avatar
  • 103
3 votes
0 answers
211 views

Automatically `\protect` arguments sent to existing command

Say you are using titlecaps and you have the following code: \documentclass{article} \usepackage{titlecaps} \begin{document} \def\makemytitle#1{{\Large \titlecap{#1}}} \makemytitle{The lazy fox ...
Andreas Storvik Strauman's user avatar
3 votes
1 answer
545 views

Redefining \bfseries command

I am trying to redefine \bfseries to become a spacing-out command. The easiest way is to redefine it as \so macro from the soul package. The trouble is, \so takes an argument (and thus is analogous to ...
Jabot's user avatar
  • 149
2 votes
0 answers
256 views

Write fully expanded macros to auxiliary files

Considering the following code snippet: \documentclass{article} \usepackage{xparse} % \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \NewDocumentCommand{\edeftest}{m}{\edef\test{#1}#1} \...
Emilio Lazo's user avatar
1 vote
1 answer
175 views

Condition statements in commands

I need to have references in some algorithms and for this I want to have a command which can take 3 parameters, the first being the key of the algorithm and the second and third being options for ...
Noor's user avatar
  • 1,801
1 vote
1 answer
619 views

Redefining Commands Using DeclareRobustCommand

I am trying to create the following commands. I want to replace \exp by a command that takes an input and outputs \exp(#1). Trying to copy something that I was shown before, I tried the following \...
Sam OT's user avatar
  • 1,338
5 votes
1 answer
331 views

scrlayer-notecolumn `\makenote` with `BibLaTeX`

Continuing my journey into BibLaTeX + scrlayer-notecolumn. I thought, once I had the BibLaTeX working with \marginpar it would all be easy. But not so. I want to create my sidebar using the scrlayer-...
Frames Catherine White's user avatar
5 votes
1 answer
151 views

Does ConTeXt have fragile commands?

A fragile LaTeX command is (link) a command that expands into illegal TeX code during the save process. Does ConTeXt "suffer" from fragile commands, or are all commands there robust?
Evan Aad's user avatar
  • 11.2k
16 votes
1 answer
2k views

List of deprecated commands and their `appreciated' alternatives

I'm wondering if there is a list of deprecated LaTeX commands and suggestions for commands that are to be used instead.
user avatar
3 votes
1 answer
126 views

Indexing and robust commands

I need to do a little massaging of my index entries before putting them into the index, so I defined a helper command. For the MWE, I'll just let the helper pass straight to \index. \documentclass{...
LSpice's user avatar
  • 1,468
1 vote
2 answers
598 views

Why does redefining \contentsname conflict with redefining \section when there is a \tableofcontents?

I am trying to modify the title of table of content and make every title of sections uppercase. But strange compilation errors occurred. The .tex file looks like the following one: \documentclass{...
Mr. Ree's user avatar
  • 121