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

0
votes
1answer
15 views

Why doesn't my \csname-based glossary macro work inside \section and \caption?

I'm a LaTeX newbie. I have a custom macro called \gloss that decorates its argument in a certain way - let's say that it adds a star symbol for the purpouse of the MWE. I have wrapped it around a ...
2
votes
1answer
24 views

Testing an existing macro doesn't work

Once defined, I don't want the macro \Stepx be redefined : \documentclass[xcolor=dvipsnames,professionalfont,french]{beamer} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} ...
2
votes
1answer
40 views

Why this dynamically named macro doesn't work?

\documentclass[xcolor=dvipsnames,professionalfont,french]{beamer} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{fourier,tikz,ifthen} \usetikzlibrary{calc} ...
3
votes
2answers
44 views

Replace from a list of possible strings

I'm creating a large number of identical documents in LaTeX, with only the address changing (and the address will be only 1 of 5 possible ) So if my list of possible addresses is: DC | 1600 ...
3
votes
2answers
50 views

How to make more-than-9-argument-commands work with tabular?

I have a command that needs more than 9 arguments. I stumbled over this solution: How to define a command that takes more than 9 arguments. This works fine in regular text. But I tried using this ...
7
votes
2answers
245 views

How to repeat over all characters in a string?

I have a command that formats a single character, let's call it \d{}. (In my case, \d{} adds a dot under a Chinese character, as this is the custom to emphasize Chinese texts). I want to define a ...
0
votes
0answers
25 views

Splitting commands over multiple lines

We have a command used to typeset things in a specific font and colour. Sometimes, what is given to this command is large and it needs to be split into multiple lines within the same align or ...
2
votes
1answer
27 views

Double backslash or \cr in \newcommand to be used in a table

I have a \newcommand*\mycmd[3]{#1 & #2 & #3 \\} that is used in a tabular environment later, like this \begin{tabular}{ccc} \mycmd{a}{b}{c} \mycmd{d}{e}{f} \end{tabular} But the double ...
2
votes
1answer
40 views

Compare Variables

I want to have a macro that checks if the string has been used in the previous call of the macro as well. I found some examples here how to create switch structure comparing strings in latex but I ...
2
votes
0answers
13 views

Using one group separator for integer part and another for decimal part (siunitx) (modified) [duplicate]

I found this link Using one group separator for integer part and another for decimal part (siunitx) the code from jfbu is almost perfect, except I need grouping of three on each side of the decimal. ...
2
votes
2answers
52 views

Check options in \newcommand or \NewDocumentCommand?

I'm trying to implement a custom command that is called like this: \mycommand[hello][world]{mandatory1}{mandatory2} OR: \mycommand[hello,world]{mandatory1}{mandatory2} However, I can't figure ...
27
votes
3answers
438 views

How to define phantoms for depth and height?

In the third "dangerous bend" on page 178 of of The TeXbook there's the following description of \vphantom: Even more useful than \phantom is \vphantom, which makes an invisible box whose height ...
4
votes
1answer
150 views

Calculate the hash (MD5 or otherwise) of a string

I'm trying to cache the results of a macro, similar to that question, but the argument of the macro can contain arbitrary characters and it's not suitable to be inside \csname ... \endcsname. So, I'm ...
5
votes
1answer
60 views

build a capitalized CS from a lowercase string and to give it a definition

Is it possible to build a capitalized Control Sequence from an argument of lowercase string and to give it a definition? I tested two codes, but both didn't work well. code1: \def\makecs#1#2{% ...
3
votes
2answers
133 views

Writing literal “#1” into an auxiliary file from a command with arguments

I am trying to write into an auxiliary file from a command with one argument. The written text is another \createcommand with one argument too. When I use "#1" the argument of meta-command is ...
0
votes
0answers
13 views

\edef together with microtype generates an error [duplicate]

In a previous question, I asked why \edef produced an error when trying to expand commands that takes an argument in the belief that this was the cause of it. But in actuality, I've realized that the ...
2
votes
2answers
103 views

Why does \edef produce an error if its arguments is a command that takes an argument?

If I have the following piece of code, everything compiles: \documentclass{article} \newcommand{\mycmd}{ \edef\tmpcmd{test} % No commands with arguments \tmpcmd } \begin{document} \mycmd ...
2
votes
1answer
63 views

How can branch if I'm in a halign or not?

Edit: It seems that I can use \noalign\bgroup before the \halign. That's fine. But how do I test that I'm inside the halign group? I'm able to write an own if, but it would be better to ask tex for ...
3
votes
1answer
27 views

How can I use \noexpand and \unexpanded without appending a space to the unexpanded tokens?

One of my current tasks involves composing an auxiliary file with extra commands to be loaded at a separate compilation. Here's an MWE: \documentclass{memoir} \newwrite\testaux ...
1
vote
0answers
34 views

Typeset code within a simple macro?

I want to use a macro to typeset programming code with the usual characteristics (particularly lines should be obeyed - this is the most important issue; highlighting and such stuff is - for now - not ...
8
votes
1answer
66 views

xparse's \DeclareDocumentEnvironment gives error on already-defined environment

I'm trying to redefine an existing environment subfigure defined by the subcaption package. To do this, I'm using xparse's DeclareDocumentEnvironment since that's suppose to declare a new environment ...
1
vote
0answers
18 views

Consistent formatting for \glft in expex

In the ExPeX documentation, all of the examples with \glft wrap the glos with single quotes; the examples in my document look the same: \pex \begingl \gla bu nɛmə // \glb this what // \glft `What's ...
1
vote
1answer
21 views

How can I include external macros for every line of the source code?

An answer to my last question gave a solution for hooking a small command onto line breaks in the TeX source. \documentclass{memoir} \usepackage[spacing, tracking]{microtype} \usepackage{libertine} ...
7
votes
1answer
90 views

Accent i in plain TeX fails inside array loop

In Plain TeX, when I try to create an array of control sequences (\word0, \word1, etc.) and print it out using a loop, TeX stumbles over the accented-i control sequence \'{\i}. I get this error: ! ...
1
vote
2answers
34 views

\newcommand error

I am using following new command: \newcommand{\legend}[3]{ \begin{itemize} \item Serial Number: #1 \item #2 \item #3%\href{http://#3}{#3}} \end{itemize} } \legend}{5, April 2015, ...
13
votes
3answers
1k views

Hooking every line of the source code

I've been considering a more radical solution to the problem k.t.hagen posed a while back. Would it be possible (perhaps by catcode hijacking) to put hooks on individual lines of the source code? ...
1
vote
1answer
58 views

Macro/shortcut for defining text portion as code

I'm currently converting my thesis into LaTeX, and i have an issue: being an IT thesis, I have tons of code quotes. The problem is not about the blocks of code: they are not that many and i can wrap ...
0
votes
0answers
59 views

Is there a LaTeX-to-HTML package that uses TeX?

I know that there are a lot of ways to "convert" LaTeX source to HTML markup that, when rendered, resembles the hypothetical original PDF. Is there such a package that works within LaTeX? I'm ...
0
votes
0answers
20 views

Putting a commonly-used piece of text in a new command [duplicate]

I am working on a document in which I need to insert a long piece of text for several times. In order to avoid writing the same long piece of text over and over again, I decided to define a new ...
3
votes
3answers
105 views

Optional newpage command

Does there exist a command (which I will call \newpageoptional) which acts in the following way: Text and code 1 \newpageoptional{ Text and code 2 } Text and code 3 The effect ...
3
votes
1answer
60 views

Style stored in command

I have created a \newcommand with some arguments that allow me to call an other command. Command syntax: \newcommand{\nodeperso}[1]{\node[\noexpand\type#1](){\noexpand\nom#1};} I have declared a ...
2
votes
1answer
46 views

Referencing custom environment

I am using \begin{figure} \includegraphics{} \caption{Caption} \label{fig:fig_name} \end{figure} and \begin{table} \begin{tabular} .... \end{tabular} \caption{Caption} \label{tab:table_name} ...
0
votes
1answer
62 views

How to repeat cell content with slight modifications on next page for longtable using multirow using LaTex

Given this approach: How to Repeat Cell Content on Next Page for \longtable using \multirow What if I wanted to slightly "modify" the text that is repeating so that on the originating page I want to ...
0
votes
0answers
40 views

Writing modular classes

As an OOP programmer, I am very attracted to the idea of making separate files for independent features within a class definition, where each feature I feel is too long to be included inline in the ...
5
votes
2answers
273 views

How to get rid of “c-cedilla” in math mode?

This code: \documentclass{scrartcl} \providecommand{\c}{\mathrm{c}} \begin{document} Complement of $A$: $A^\c$. \end{document} Produces the following error: ! Missing { inserted. <to be read ...
1
vote
1answer
65 views

How to name arguments in \newcommand?

How to name the arguments in \newcommand so that when you call the macro they don't appear as {arg1}{arg2}... etc. but with the names each argument represent {caption}{label}... etc. without the use ...
3
votes
0answers
39 views

mouse over (highlight) acronyms using acronym package. is that possible?

Is it possible to highlight acronyms (mouse over shows the acronym definition) by using the acronym package \ac ....? In this post, there is a macro that was working somehow but by using the acro ...
0
votes
0answers
25 views

Creating a myenumerate-environment with a counter [duplicate]

I want to have the counter use roman numbers, so it should be something like: (i) ... (ii) ... (iii) ... I tried defining a macro \myitem, but it´s not really working. Does any have any ideas?
9
votes
1answer
135 views

Somewhat versatile usage of \@gobble and \@firstofone found in several macros

I was doing search about my question (see here for more detail) and found a thread commath and \ifinner. In the thread, there is a macro named \spx , the definition and usage of which are extracted ...
2
votes
1answer
53 views

Can one modifiy an argument within its macro?

I wish to give a default value to a series of arguments when they are empty. I could make a test prior the use of the argument and modify the value just before each of the usage. I could even make a ...
11
votes
2answers
109 views

Calling non-\long macro as \long

Suppose a given macro is not already \defined \long, but I want to call it with \pars in the argument. Is there any way to turn off TeX's error checking for one call? What I have been doing is ...
7
votes
3answers
150 views

How can I use or represent special characters like \ and { inside \csname…\endcsname?

I want to \def a macro with a name that represents arbitrary string data, including the \, { and } characters. My initial approach was to use \textbackslash and \{ to test that I could do this. But ...
0
votes
1answer
37 views

Conditional branch with \ifinner and Spacing in higher derivative (2 independent questions) [duplicate]

I made some macros shown below, which outputs ordinary/partial derivative. I was checking whether they work as I expected, and found that \dif{y}{x} expands to \tfrac{\difd y}{\difd x} in align ...
5
votes
3answers
99 views

how to toggle displaying English and Chinese content, and always showing math content?

I'm about to draft a document that each paragraph will have English and Chinese version, and there are also some math formulas. For example, suppose the latex content is something like this: English ...
1
vote
0answers
14 views

How to change font type faces in table row? [duplicate]

Is possible to change font faces in whole row on similar way as it is possible for columns? \documentclass{article} \usepackage{array} \begin{document} \begin{tabular}{>{\bfseries}c ...
1
vote
3answers
75 views

Set custom commands

Very often I have to write \text{im}(f), to denote the image of f, if I try to write, \im f, then it generates the Imaginary notation which I do not want, if I write im f then it looks awful. Is there ...
10
votes
1answer
154 views

\newcommand and its intricacies

I recently came across the following command: \newcommand{\minitab}[2][c]{\begin{tabular}{#1}#2\end{tabular}} Well, this is close to the syntax laid out on p.845 of TLC, but I still don't ...
3
votes
3answers
161 views

How to use args of macro as part of function's name? like \foo#1bar -> \fooargbar

How to call the function using macro arguement #1 as a part of name of that function? It is analogue of #define in C++. The code will describe you the simple idea: \newsavebox\QAAAX ...
5
votes
2answers
179 views

Capacity exceeded while implementing lookup table

I'd like to implement simple key-value lookup table. I wanted to do it in functional fashion, so I've defined initial state of such table as get function causing error (as table is initially empty). ...
1
vote
1answer
62 views

Redefine \LaTeX command

From How can I see the "implementation" of the \LaTeX command? and How to write (La)TeX (with parentheses) [or any other TeX-related logo], I learn that \LaTeX is implemented as L\kern ...