Questions tagged [robust-commands]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 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 ...
  • 6,831
4 votes
2 answers
281 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 ...
  • 315
4 votes
1 answer
50 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 ...
  • 24.5k
0 votes
1 answer
14 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 ...
  • 902
0 votes
0 answers
33 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 ...
5 votes
3 answers
421 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\...
  • 522
0 votes
1 answer
73 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 ...
  • 417
3 votes
1 answer
35 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{\...
  • 522
5 votes
1 answer
239 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. ...
8 votes
3 answers
831 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...). ...
  • 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 ...
  • 913
3 votes
2 answers
53 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 \...
  • 96.7k
4 votes
2 answers
192 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 ...
  • 143
0 votes
1 answer
41 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 ...
  • 3
1 vote
1 answer
166 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 ...
  • 2,125
3 votes
2 answers
146 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 ...
  • 247
2 votes
2 answers
143 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: \...
0 votes
1 answer
81 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 ...
0 votes
0 answers
77 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? ...
  • 2,034
2 votes
1 answer
237 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{...
1 vote
0 answers
163 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 ...
  • 723
3 votes
1 answer
65 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 ...
1 vote
1 answer
192 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} \...
  • 377
2 votes
1 answer
206 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{...
  • 284
4 votes
2 answers
92 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 ...
0 votes
0 answers
229 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: \...
  • 177
2 votes
0 answers
167 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 ...
0 votes
1 answer
132 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, ...
  • 103
3 votes
0 answers
175 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 ...
3 votes
1 answer
411 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 ...
  • 137
2 votes
0 answers
218 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} \...
1 vote
1 answer
149 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 ...
  • 1,711
1 vote
1 answer
413 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 \...
  • 1,169
5 votes
1 answer
276 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-...
5 votes
1 answer
137 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?
  • 8,886
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
99 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{...
  • 1,162
1 vote
2 answers
504 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{...
  • 121
7 votes
3 answers
473 views

\def inside of \def not visible in titles or captions

The following MWE yields a compilation error: \documentclass{article} \usepackage[english]{babel} \begin{document} \def\AAA#1{\bgroup\def\contents{AAA}#1\egroup} \def\BBB#1{\bgroup\def\contents{BBB}...
  • 3,934
2 votes
1 answer
243 views

random numbers scaled into parametrized intervals

MOTIVATION: To point shade a diagram. Points have random coordinates. They cluster around hidden user input coordinates more or less far out depending on those inputs. How would one use \...
8 votes
1 answer
230 views

Passing a macro defined by \newrobustcmd to another macro causes some problems while \DeclareRobustCommand doesn't!

I wrote a macro for slicing any part of string. It works with ordinary strings but when a string defined with \newrobustcmd passed to it, the macro doesn't work and causes error. (in case of using \...
  • 2,332
8 votes
7 answers
4k views

newcommand with comma separated argument, and optional arguments

I want to define a command (not with \def) the simplest possible way that it takes arguments separated by a comma, supports an optional argument (the first one). maybe another solution with extra ...
  • 1,660
4 votes
1 answer
1k views

Robust commands

What is the primary reason to \protect new definitions or macros, or use \DeclareRobustCommand rather than just \def? (If it is primarily to do with better error messages, I personally can live with ...
1 vote
1 answer
279 views

Command line option to get tree view structure of LaTeX project

I would like to get a tree-view of a latex project showing things like sections, chapters, figures. - Table of contents - Introduction (1.0) --- fig 1 fig one title --- fig 2 fig two title - ...
15 votes
1 answer
462 views

A robust command for French-style intervals

In France, we usually write open or half-open intervals as ]a,b[ or [a,b[, not (a,b) or [a,b). I especially do not like (a,b) as it can be confused with an ordered pair. I have therefore defined an \...
  • 1,247
8 votes
3 answers
773 views

Cause DeclarePairedDelimiter to switch starred and nonstarred versions

I've made lots of use of the answer here, which shows how to switch the starred and nonstarred versions of a paired delimiter command (causing the regular version to automatically size the delimiters)....
2 votes
0 answers
62 views

Can I force a pre-process action on all commands or environments without having to redefine them all manually?

I am trying to preserve a history of the latex commands and environment initializations I use in a typeset html or pdf file. Is there a way where I can force a pre-process action on all commands ...
  • 3,955
5 votes
0 answers
193 views

Strings and memory usage [closed]

The TeX engine was originally written in Pascal before dynamic memory allocation was generally available. Modern implementations tend to be done in C. To qualify as TeX an implementation has to pass a ...
  • 71.4k
5 votes
1 answer
2k views

Use \raisebox with \depth in caption

I want to use \raisebox in a caption. I know that \protect is often needed in these situation, but this (and other combinations I have tried) does not work: \documentclass{article} \begin{document} ...
  • 5,172
7 votes
1 answer
322 views

Clarification about moving arguments

I was reading in latex2e about the use of \protect. In section 13.8 it mentions "expressions in tabular and array enviornments" as examples of moving arguments. I was a bit surprised by this. Could ...
  • 49.2k