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

2
votes
0answers
11 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
46 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 ...
24
votes
3answers
354 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
148 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
56 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
132 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
99 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
62 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
25 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
32 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 ...
0
votes
0answers
16 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
88 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
57 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
59 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
39 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
64 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
36 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
24 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
134 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
52 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
108 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
148 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
158 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
174 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
61 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 ...
0
votes
0answers
30 views

how do i change letter in address from capital letter to normal letter in amsart

I want to a form as following: title^* author^1**, author^2*** and author^3**** ^1 adreess of author1 (normal letter not capital letter) ^2 adreess of author2 ^3 adreess of author3 abstract keyword ...
1
vote
1answer
68 views

“Good” command names for typesetting matrices and vectors

I usually add \newcommand{\M}[1]{\bm{#1}} % Matrix \newcommand{\V}[1]{\boldsymbol{\mathbf{#1}}} % Vector to my preambles. Short command names because I use them very often. Is ...
0
votes
0answers
20 views

beamerarticle and minor problems with caption

I have a major and some minor problems with the MWE below. The major one: when I uncomment \usepackage{beamerarticle}, my macro definition starts to contain some extra '}', probably some macro ...
3
votes
2answers
44 views

Redefining `interval` to always be scaled

I already tried something like this: \let\oldinterval\interval \renewcommand{\interval}[2]{\oldinterval[scaled]{#1}{#2}} The problem is that I can't use \interval[open] anymore. Is there anyway to ...
7
votes
1answer
37 views

What's the most plain way to define a parametrized macro within an outer macro definition

I often want to pass some arguments into a macro definition that defines an inner macro with parameters. For example \def\outmac #1,#2.{% \def\argone{#1} \def\argtwo{#2} \def\inmac ...
6
votes
2answers
183 views

Replace digits by arbitrary symbols

I want to write some macro that replaces all digits in its argument by previously defined symbols or macros. I envision something like \overrideDigits{1234567890} which should expand to something ...
1
vote
0answers
8 views

Namespace for theorems [duplicate]

I want to make a theorem \newtheorem*{def}{Definition}. This doesn't compile because \def is already defined. How do I make amsthm use a different namespace for theorems? It doesn't make sense for a ...
1
vote
1answer
55 views

Putting a \newcommand in a tabularx

I have two command I have created with \newcommand, both work find. One is \mydate{date_variable} the other is \PrintOne{Variable1}{Variable2}. My problem is I can not figure out how I can put them ...
28
votes
1answer
611 views

What does “expanding” mean in (La)TeX?

You can often read about expanding a macro or when a macro does expand, sometimes about expansion. But what does this mean - in English?