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

1
vote
0answers
25 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 ...
2
votes
1answer
23 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
100 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
36 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
63 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
92 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
116 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
63 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
48 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
70 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 ...
1
vote
0answers
77 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
295 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
83 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
50 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
30 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
148 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
54 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
117 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
187 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
38 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 ...
6
votes
3answers
105 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
83 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
162 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
183 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
198 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
80 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
36 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
88 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
29 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
50 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
40 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
194 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
59 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
645 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?
3
votes
2answers
75 views

Applying MakeUppercase to non-English characters in math mode

I have some macros to distinguish between two varieties of similar objects. So, for example, I need \psi to come out as expected, but \MakeUppercase{\psi} to come out as \Psi. (Obviously my real ...
5
votes
2answers
251 views

New environment, orphan line

I created three environments for my document: a booklet for a treasure hunt with scrreprt. I created 3 environments (the document is in french): enigma: ...
1
vote
1answer
42 views

How to create multiple dotted lines

I want to create multiple dotted lines, I found this code on the internet \newcommand{\Pointilles}[1][3]{% \multido{}{#1}{\makebox[\linewidth]{\dotfill}\\[\parskip]} } The problem ...
3
votes
3answers
364 views

Can I use (LaTeX?) packages from CTAN in plain TeX?

I have the following assumptions: TeX is a kind of language Plain TeX is the original environment for this language LaTeX (and other environments) is a set of compiled macros written using TeX ...
3
votes
3answers
68 views

Saving counters

Consider the situation: Two authors A,B (in fact, it will be four) inserting comments on a tex file. Each author has his own command \alertA and \alertB to insert comments. Each author should has ...
1
vote
0answers
31 views

Passing background color to \lstinputlisting

In question Passing parameter in presence of an xkeyval value I received two ideas for dealing with passing an option to a macro. Namely, \expandafter\lstset\expandafter{\ME@options} and ...
5
votes
2answers
78 views

Using later defined macro values

Is there a way to get something like \test \newcommand{\test}{Print me!} to work in the same manner as \newcommand{\test}{Print me!} \test would work? Basically I'm wondering if I can set a ...
1
vote
1answer
68 views

Generating a list with macros using tasks package

I cannot figure out how to generate a list with the tasks package using macros. If you swap the three identified lines in the MWE below, you should get the following error message: \begin{tasks} on ...
3
votes
1answer
82 views

How to define a command that defines another command?

I have a command defined with xparse that looks like this: \NewDocumentCommand{\ME}{sogd<>}{\added[id=ME,remark={#1}]{#2}} (for the full code see Passing complicated argument patterns to a ...
16
votes
3answers
296 views

The meaning of \@@

A couple of times in the latex.ltx kernel, the macro \@@ is used. For instance in the definition of \@next (l.6222): \def\@next#1#2#3#4{\ifx#2\@empty #4\else \expandafter\@xnext #2\@@#1#2#3\fi} ...
2
votes
1answer
78 views

Include LaTeX commands from external file in asymptote file

I have many asymptote drawings in a .asy file whose generated pdf is included in a main.tex. I have many user-defined commands, like \vec or \vxi which I use in my current main.tex and I want to use ...
1
vote
1answer
47 views

auto-completion of \eqref

All references are marked with eq -> equation tab -> table fig -> figure app -> appendix sec -> section chp -> chapter So a reference would look like \label{eq:NT_LoM} \label{sec:intro} for ...