{macros} is for questions specifically concerning TeX's macro processor. Note that, because TeX uses macros ubiquitously, most questions about code that uses macros are not looking for information about how macros work, and so are not appropriate for this tag.

learn more… | top users | synonyms (4)

3
votes
1answer
62 views

newcommand with two arguments, one optional

I'm struggling with a command that doesn't do what I expect. This is my code \newcommand{\expectation}[2][]{\mathrm{E}_{#1}\left[#2\right]} \begin{document} I get $\expectation{A}{B}$, but I expect ...
1
vote
1answer
32 views

Having acronym processed differently if used in acronym environment

I have a number of acronyms that depend on each other and I would like a way to determine if the usage of an acronym is in the acronym environment and if so process it in a different way than if it is ...
2
votes
1answer
47 views

Code for capital letter in acronym list clashes with other custom commands

I am writing a large report with many acronyms, some of which include each other. I asked about a way to let them do this in a specific way and got a very nice answer. Acronyms that include other ...
1
vote
2answers
20 views

Error while defining custom tabular column width

I am trying to define the maximum width of a tabular column, see the code below: \documentclass{article} \usepackage[]{float} \usepackage[]{hyperref} \usepackage[]{booktabs} \usepackage[]{array} ...
1
vote
1answer
23 views

Specific formatting for some entries of a glossary

I use the memoir class. In my glossary, I need to emphasize certain terms (and descriptions), but let the others in roman. The command is \glossary{term}{description} so I tried to do ...
3
votes
1answer
63 views

How to remove highlighting color?

How would you remove highlighting color from LaTeX with one command? I have used the soul package with its command \hl.
4
votes
4answers
155 views

Newcommand: underbrace parentheses

I need a newcommand like \underbrace{}_{}, but I want a parenthese like that ( instead of {.
2
votes
1answer
73 views

Is it possible to access command parameters?

I use hyperrefs extensively in my document and I define them like this: \hyperref[label]{some text \ref*{label}} It's really annoying that I need to repeat the label twice. Is it possible to ...
15
votes
2answers
313 views

Environment to stack a word and a number

There is a requirement to write a list of words, underline each word and place a number centered below the line. Using the stackengine package I have prepared the following MWE. ...
2
votes
1answer
20 views

Using user defined commands within Tikzcd

\documentclass{article} \usepackage{amsmath,amscd,amssymb,amsthm,graphicx,amsxtra} \usepackage{verbatim} \usepackage{tikz-cd,xparse} \usetikzlibrary{matrix,arrows,decorations.pathmorphing} \newcommand ...
6
votes
2answers
92 views

TikZ Macro for Placing an “X” by Coordinate

I would like to make a TikZ macro that will: Have an optional argument of coordinates Place X centered at those coordinates. Is this possible? This is how I put two X's on a 10x10 grid manually. ...
0
votes
0answers
28 views

change the default sidecaption margin at left for oneside memoir option

This question is related to this stack thread About \sidecapmargin Memoir class say that the \sidecapmargin command controls the margin where the sidecaption will be placed. The possible values ...
2
votes
1answer
30 views

How to access per-page variable/command for use in footer

What I would like to accomplish is including a per-chapter variable/command in the header (or footer, would be the same issue). The real crux of this question is, I supposed: how would one include a ...
5
votes
2answers
110 views

How to define a newcommand that expands into another newcommand

I'm not sure exactly what terminology to use to ask this question. What I want to do is define a command pluralize such that I can do this: \newcommand{\individual}{individual\xspace} ...
1
vote
1answer
24 views

Variables defined but used in a class file & want to specify value in tex file

I'm new to TeX & I "inherited" a tex document & class file. The class file has: \newtoks\copyrtyr \newtoks\acmcopyr \newtoks\boilerplate \def\CopyrightYear#1{\global\copyrtyr{#1}} ...
0
votes
1answer
45 views

Comparing macro arguments

I'm trying to compare a and b from \f{a} and \g{b}. It could be done by redefining \f and \g so that they expand to their argument, then comparing the arguments and finally resetting \f and \g's ...
4
votes
2answers
52 views

\xpatchcmd fails in a more complicate command

I've tried to patch the \minitoc@ command to add some additional vertial spacing after \mtctitle is used. (This is a question resulting from Adjust vertical spacing between minitoc title and contents) ...
4
votes
4answers
456 views

One-liner for removing characters from a string

I have a predefined command \mycommand which, for some reason, outputs {"/home/user/di rect ory/"/}. (Yes, there's a slash after the quotation mark, and there are curly braces.) Could one think of a ...
1
vote
1answer
57 views

Would it be possible to embed the lambda calculus in TeX?

I understand that TeX is Turing-complete. I'm just curious: would it be possible to embed the lambda calculus in TeX using TeX macros to fulfill beta-reduction?
3
votes
1answer
44 views

Moving past the next group - `\hop\thing{\args}` → `\thing{\args}\hop`

This is a followup question to Eating commands (where I got the code for \e which I am trying to adapt to make \ep work. \e rewrites the next token into e if it is \f and leaves it alone otherwise. ...
7
votes
2answers
372 views

Eating commands

I don't understand why this code behaves as it does: \newcommand{\f}{f}% food \newcommand{\s}{}% stop eating \newcommand{\h}[1]{h}% hide food \newcommand{\e}[1]{% eat \ifx\f#1 e \else #1 ...
0
votes
0answers
29 views

how to change colour new command [duplicate]

is there any possibilities to declare a different colour for this? \makeatletter \newcommand\mysphere{% \parbox[t]{5pt}{\raisebox{0.2pt}{\beamer@usesphere{item projected}{bigsphere}}}}%{\color teal} ...
2
votes
0answers
41 views

Display shortcuts other than urls with href

Big picture, I am trying to develop an approach that will allow me to store the latex commands and labels (pre-expansion) that I use to typeset dynamic text (bib entries with cite, cross referencing ...
6
votes
3answers
69 views

Why does \def fail inside \edef?

An answer to one of my previous questions provided this code for referencing a range of lines in which a line labels were placed at the beginning and end of the line range. \makeatletter ...
0
votes
1answer
23 views

Overrinde the functionality of a user-defined macro

I want to add an option to the document class which will allow me to modify definition of a single macro. The option which declares the macro \ifthenelse{\boolean{nicepaper}}{ ...
7
votes
4answers
192 views

\newcommand with options

My question is about declaring a "newcommand" with an option. I have defined \newcommand{\bforall}[2]{\forall #1\, (#2)} so that $\bforall{x}{x \in A}$ writes $\forall x (x \in A)$. I would like ...
3
votes
1answer
66 views

Merge consecutive linebreaks

I have something like this : %\newcommand{\maybehide}[1]{#1} \newcommand{\maybehide}[1]{} \newcommand{\thing}[1]{#1} \newcommand{\bigthing}[1]{#1} \bigthing{ \thing{1}\\ \maybehide{\thing{2}}\\ ...
4
votes
2answers
45 views

\nameref with quotes

How can I redefine the \nameref command to have the referenced caption in quotes? Here is what I have tried: \documentclass{article} \let\oldnameref\nameref ...
33
votes
3answers
727 views

Do fontsize environments exist?

Without any doubt there are fontsize switches in the form of control sequences (described here for instance.) But, from time to time I ran into code examples where environment versions of those were ...
2
votes
0answers
28 views

Why must parameters for inner macro definitions double each #? [duplicate]

Or "When would an expression like ###1 be useful?" In macro programming, it's a well-known rule that you need to double your parameter identifiers with each successive layer: \def\insult#1#2{% #1 ...
1
vote
2answers
36 views

Removing annoying braces/brackets

I have a command that works with this syntax: \startmycommand[{ nononononononononononon nononononononononononon nononononononononononon }]\endmycommand A user has provided a(n) (excellent) ...
2
votes
0answers
34 views

(Is it wrong to) Use commands to begin and end equations (?) [duplicate]

I'm helping a professor write the second edition of his book, so I'm working with a lot of "old" code and bad practices. Something I've found is that he has defined macros for beginning and ending ...
5
votes
1answer
46 views

Why does it appear that some lineno internal commands are never called?

At the end of lineno's cryptic documentation, the author lists certain "for wizards commands." I'm trying to implement a special tag for the first line number, so I thought I would probably begin by ...
4
votes
1answer
63 views

Defining multicolum by macro with optional argument

I try to define macro for shortcut form \multiline{1}{<pcolumn type>}{\textbf{text}}: \documentclass[12pt,border=1mm,preview]{standalone} \newcommand\mcbf[2]{\multicolumn{1}{#1}{\textbf{#2}}} ...
2
votes
2answers
40 views

Merge double subscripts in macro

I would like to define a macro \des that has one argument and adds a subscript to it i.e. \des{a} should correspond to a_{des}. So far the solution is obvious, however the macro should also accept ...
2
votes
2answers
76 views

Definition of a macro with multiple arguments and usage of \csname

Why does the following code not work ? \Requirepackage{amsthm} \renewcommand\newtheorem[2]{% \NewEnviron{\csname #1\endcsname}[1]{% ##1 : \BODY } } I have seen examples of the use ...
1
vote
1answer
22 views

Use macro as totcount counter name

In the top level of the document environment, a macro defined (using \def) can be expanded into the name of a totcount counter. This, for some reason, does not work inside an environment definition. I ...
2
votes
1answer
196 views

Define a command with an odd number of braces

In my code, I change to '2 columns' mode typing: \twocolumn[{ I'm trying to simplify this code, by creating a new command: \renewcommand{\twocolumn}{\twocolumn[{} Is this possible to insert a ...
1
vote
0answers
47 views

Define new command using \DeclareTotalTCBox in tcolorbox package [closed]

I have defined a command using \DeclareTotalTCBox command in tcolorbox package as blew: \documentclass{article} \usepackage[most]{tcolorbox} \DeclareTotalTCBox{\myverb}{ O{red} v O{} } { ...
4
votes
3answers
214 views

Amplifying fractions

I want to make myself a math portofolio (as a quick reference) and I have a part where I have to 'amplify' a fraction like here: But I don't know how can I do this thing, can you help me? Thank ...
3
votes
3answers
107 views

Expl3: Constructing command sequences from macro arguments

In my LaTeX laboratory I am doing weird experiments with expl3 (just started to use it some days ago, so regarding l3 I am complete newbie) I am trying to generate command sequence within of another ...
1
vote
0answers
40 views

how to expand some macros in latex file [duplicate]

I have a latex file that uses some of my own macros (a mix of tex & latex macros). I need to post the latex source, but don't want to expose the macros (some of which are nasty hacks that just get ...
4
votes
1answer
86 views

Can you interpret macro parameters as verbatim?

Basically I want to define a macro whose parameter should be treated as a "script", meaning that I want to print it in a verbatim way including line breaks and special characters. Furthermore, I want ...
2
votes
1answer
66 views

Can a command be defined to have key=value in it?

I am learning about making LaTeX commands. I thought that they were just macro, and the command is replaced literally by its definition. But the following example does not work and I wanted to ask if ...
3
votes
1answer
79 views

Items from file in itemize enviroment

Is it possible to import items from a file into an itemize environment? For example, consider a file with just words and no formatting: Elem1 Elem2 Elem3 Elem4 ... Elem120933 I like to read in this ...
6
votes
1answer
47 views

Define nested sections in a relative way

When working with large tex documents I often find myself using search/replace to restructure them (eg. make sections out of chapters or subsubsections out of subsections) Is there any way to define ...
2
votes
2answers
156 views

how to define newcommand that takes []{} as arguments and not {}{}?

I find myself doing a lot of things like this below in order to compile document for both pdf and tex4ht \ifdefined\HCode \includegraphics[width=0.5\paperwidth]{foo.eps} \else ...
2
votes
1answer
65 views

etoolbox package explanation requested

I am trying to understand the following package etoolbox. I am unsure about the meaning of the following syntax since I am not sure what is the correct question to ask in google or in the book of ...
7
votes
4answers
158 views

Detect if a macro argument is only one symbol

I define a bunch of functions (or operators, if you like) using a little helper \parens, which adds parens on demand: \newcommand{\parens}[1]{ \ifthenelse{\equal{#1}{}}{}{(#1)} } ...
4
votes
2answers
53 views

Problem with gb4e and macro for tabular with curly brackets

When using the macro \CurlyBrackets at the beginning of a gb4e example, the example is not typeset as expected. Is there a better way to do this to get the desired output? MWE ...