{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
2answers
59 views

How to implement a macro for normal ordering of operators?

I am looking to typeset the normal ordering symbols :O: commonly used in quantum field theory in a way that makes them easily discernible from regular colons, especially the 'defined as' symbol :=. ...
9
votes
4answers
430 views
+50

How to replace text

I'd like to write something like this: \replace{Text should be replaced here, here and here}{here}{Latex} It should outpout Text should be replaced Latex, Latex and Latex How can this be ...
7
votes
2answers
200 views

“Flatten” macros prior to sharing LaTeX file

Is there a way/an existing tool to process a LaTeX source document such that for a given list of macro definitions (using \newcommand), calls to those macros are replaced by their expanded version? ...
2
votes
1answer
35 views

newcommand: boldface is extended to next character

I am using a newcommand like this \newcommand{\gen}{\textbf{P1}\xspace} and it works just fine. However in the text the boldface is always extended to the next character. For example lorem ipsum ...
1
vote
1answer
21 views

changes package for peer reviewed journal: hide authors and convert 'replaced' to 'added'

I'm using the changes package to keep track of any changes I ( and my co-authors ) made for a peer reviewed journal. Meaning, in response to each of the reviewers' comments, we are using a new author ...
1
vote
1answer
68 views

image height reduce/increase automatically

I have the below boxed environment. The image should place in the marginpar width. When my environment is going long the image should automatically increase upto my enviroment, when is going to low it ...
3
votes
1answer
12 views

\if leqno or reqno: command to check whether left or right eq. Numbers were set

I am defining my own command and need to check, which mode the user has set, whether reqno or leqno. Is there a way to do this?
37
votes
2answers
11k views

newcommand vs. DeclareMathOperator

As far as I understand, whatever can be done using DeclareMathOperator can also be achieved using newcommand, but not the other way around. If this is the case, what are the circumstances where ...
3
votes
1answer
42 views

Correct superscript spacing for new mathbin

I redefined the \div command so that it's U+2215 aka ∕, but for some reason when I use it as a superscript the spacing between this symbol and its numbers is really tight (works fine in displaymode or ...
2
votes
0answers
49 views

How to make a function inside the tikzpicture behave like outside

I have a makro which generates a structure(rule) and a reference to that structure. It does not behave when inside a tikzpicture. How to make the function robust to reference the structure even when ...
0
votes
0answers
34 views

Is there a semantic definition command?

Every time I want to emphasize a definition word in a paragraph I need to explicitly state the formatting with \mathbf{<word(s)>}. But I'd like to use a semantic command like ...
9
votes
3answers
145 views

How to parse multiple arguments in TeX macros

I have dates formatted {yyyy-mm-dd}. I would like display the time elapsed between the dates in the form Y years, M months. Given the format of the dates, it seems easier to use arithmetic than to ...
7
votes
1answer
620 views

Where are the biblatex macros defined?

Today I wanted to modify some of biblatex's bibliography driver macros (in my special case it was the url+urldate macro). My plan was to copy the macro from the biblatex package of my TeX distribution ...
0
votes
1answer
35 views

Expand second argument/counter

I'm currently working on a somewhat automatic way to generate B+ trees. Thus I introduced a new macro to generate the content of a matrix of nodes which should also generate the labels automatically. ...
3
votes
1answer
33 views

How to pass parametres to an external file included by `\input{<filename>}`

I have a class file to set up agreements. I want to define a command that choose boilerplate text to include using a parameter pass a parameter to the included file to run a test and choose correct ...
1
vote
1answer
58 views

Chapter Opener in both Right and Left Side

I would like to get the below chapter opener with back-end Image in my LaTeX file. 1) BackEnd Image 2) Front End Chapter Number and Chapter Title. 3) Yellow Color box is backend and what you will ...
2
votes
1answer
70 views

Passing a command as an argument

I got a solution for my quoestion about Smaller roofs for forest but I want to pass a command instead of text to a procedure and this causes an error: ! Argument of \@rsbox has an extra }. ...
7
votes
1answer
85 views

New command to number paragraphs (related counter)

I use KOMA class (scrbook). My goal : I try to create a command (let's say \verset) that will display a number, each time indented. A title should be put as argument An example : \verset \lipsum ...
4
votes
1answer
60 views

Strange preamble for a thesis or this is normal?

I have a somewhat strange template that I should use for submit my dissertation for the speciality. I put the code as a minimal working example for you to see: ...
1
vote
0answers
27 views

Problem with answers using hyperlinks and tbox

I have minor problems with the solutions shown in Hyperlink with answers package I wanted to make a macro which takes solution and exercise as arguments, uses a button like mutual reference, and ...
83
votes
2answers
46k views

How do I create an invisible character?

I cannot remember how to create an invisible character in LaTeX, i.e. I want to put a space the that has the width of a particular character, say `M'. I know there is a command for this, and this is ...
1
vote
1answer
48 views

How to parse a macro that contains a \let?

My situation is similar to, but hopefully different from How do I ‘expand’ a control sequence \let to a character?, as that question does not admit a positive answer. I want to parse, not expand, but ...
23
votes
2answers
685 views

Please tutor the usage of patchcmd and xpatch

I understand that the patchcmd package provides a command \patchcommand that can be used to add material at the beginning and/or end of the replacement text of an existing macro. It works for macros ...
10
votes
3answers
750 views

Are commands defined by \newcommand[.][.]{.} robust?

This question is from the comments at the foot of Abbreviations for AM, PM (small caps) for use within \textbf. Readers will get the remaining gist from there. With ...
0
votes
0answers
50 views

Overlay specifications in beamer

I'm trying to create a beamer document class (.cls) with some configurations that please me. But, I ended in this point where a cannot overlay my \newcommand. This code has to collect a few ...
3
votes
1answer
32 views

Using \newcommand to display user input that may contain special characters that need to be escaped

I don't know much about LaTeX right now, but I need to be able to use it to generate dynamic PDF documents using C#. For the most part, everything is cool and works the way I want it to work. ...
1
vote
1answer
35 views

Placing the text under a line in a multiline form

I am typing a form like the following: I want to make a command \newcommand\myform[1]{ *** #1 ***} that will produce the filled-in form with the argument substituted into it. For example, the ...
2
votes
1answer
357 views

Using a string defined with \newcommand as a function argument

I'm currently using LaTeX to make a poster, which is all going very nicely. However for each of the seven boxes on the poster, I've got to pass eight arguments which may change in the future. I ...
4
votes
2answers
88 views

Processing “List” of “List”

I implemented a short macro that processes a comma separated argument list to format them. So by calling \macroa{ABC, DEF} it will format the text to ABC DEF Now what I would like to have is ...
0
votes
0answers
10 views

Using a comma-separated list for a cycle macro [duplicate]

I am doing abstract algebra and it is rather tiring to have to write \begin{pmat}1 & 2 & 3\end{pmat} or something of that nature every time I want to write a cycle. I was thinking of a macro ...
2
votes
1answer
46 views

How to refer to a word inside a running text as a TikZ coordinate?

Say you have some running text, and you want to be able to refer to some part of that text (like a single word) as a TikZ coordinate in order to, for example, draw edges to that word. What's the best ...
1
vote
1answer
28 views

Inserting command with optional argument as optional argument Problem

If I define the following two commands: \newcommand{\TestA}[1][]{a^{#1} aaa} \newcommand{\TestB}[1][]{#1} and then call it by $\TestA[\TestB[111]]$ I get the error: "Argument of \\TestB has an ...
3
votes
1answer
73 views

Generating Labels via Macros and loosing \ref{}'s

I want to write a macro which will include labels. When I generate a label with the macro I don't seem to have access to it in the list of Gathered resources provided by Winedt 9. I really want the ...
3
votes
4answers
92 views

Too many Sums: “TeX capacity exceeded ”

I am a lazy student who writes a lecture in LaTeX. As I need many \sum\limits and \int\limits I tried to overwrite the command \sum\limits so I just have to write \sum. So I wrote ...
1
vote
1answer
64 views

Extracting text from variable

I am trying to work out a special document that through a seed generates a test for my students. I have gotten quite alot to work but I have the issue that when I try to add my answers into an array ...
2
votes
1answer
56 views

Create a command for a different font

I'm pretty new to Latex and I am writing my thesis. I would like to use a command that I can essentially change the font of a few words in-line or separate (like an equation). I have computer ...
5
votes
1answer
30 views

Anchor macro for paths

I am trying to build a macro to assign anchors for a given path. This is what I have: beginfig(1); def anchors(expr p) = pair p.n, p.e, p.s, p.w; p.n := .5(ulcorner p + urcorner p); p.e := ...
6
votes
1answer
41 views

More robust macro for ranges AND series of lines, measures, etc

Starting with @egreg's marvellous xparse answer to my question about a Macro for abbreviated ranges (pages, music measures), how to define a similar command that can also handle non-contiguous ...
3
votes
3answers
120 views

Safe test for an empty expanded macro argument?

How can I test in a safe way (i.e. without reserving tokens as explained here) if an expanded macro argument is empty?
11
votes
3answers
321 views

Parser for decimal numbers in (plain) TeX

I need help writing a parser for decimal numbers using only TeX and plain TeX. The set of accepted inputs is given by the regular expression: (+-)?(0-9)*(.,)?(0-9)+ The parser need not do anything ...
4
votes
1answer
61 views

Macro for abbreviated ranges (pages, music measures)

I would like a semantic, configurable way to input ranges of pages, poetic lines, and music measure numbers. Using a macro would enable me to make sure all such ranges are formatted consistently, and ...
6
votes
1answer
66 views

How to use macropackage in LaTex?

I have used LaTex amspackage to type a math article. The publisher is asking me to do it in Springer LaTex macropackage with the option of 'smallextended.' I have no idea how to do this. Help please!
5
votes
5answers
184 views

Define a macro based on parameter

I am trying to create a macro that creates two macros. The first sets a default value and the second creates a macro to redefine the first. I am trying to generalize a common pattern I am using quite ...
0
votes
1answer
54 views

Using `\cronominutes` with Antibes theme

This is a nice post that discusses the use of the \tdclock package. Following the tex demo provided in its answer, I modified my MWE below to use a stopwatch with the macros \cronominutes of that ...
1
vote
1answer
16 views

Appending to macro name in a metacommand [duplicate]

I'm trying to build a macro that in-turn generates a couple related commands. Here's a really simplistic example: \documentclass{article} \newcommand{\myabbv}[3]{% \newcommand{#1}{#3} ...
6
votes
1answer
40 views

How to return \count value from \def

I wrote a macro which calculate remainder : \def\remainder#1#2 {% \newcount\dividendcount \dividendcount=#1 \newcount\quotientcount \quotientcount=#1 \divide\quotientcount #2 ...
7
votes
1answer
138 views

Reversing the effect of a \newline with the next command?

I'm using the harvard package and the agsm bibliography style. I'm aware that there are alternatives, e.g., natbib plus har2nat, and I will be looking into those in the not-too-distant future, but at ...
0
votes
0answers
98 views

Mass replace custom macros in a LaTeX document?

I'm typesetting a document and to make it more editable I'd like to find a nice way to write the document making custom commands left and right for my ease, then go and replace them with their ...
0
votes
0answers
25 views

Reassignment macro doesn't work inside title, if protected “works” but not styled

A handy macro egreg made works famously, but not so well in titles. \protecting it prevents TeX from dying, but then it seems to be hidden from \spacedallcaps. \documentclass{article} ...
5
votes
1answer
129 views

Macromize a tikzfigure

I have this figure (/ 2 figures) \documentclass{article} \usepackage{pgfplots} \usepackage{subcaption} \newcommand{\xfigscale}{.5} \newcommand{\yaxscale}{.75} \begin{document} \begin{figure} ...