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

4
votes
1answer
79 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 ...
3
votes
3answers
149 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?
2
votes
1answer
84 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 ...
0
votes
1answer
76 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 ...
6
votes
1answer
68 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!
1
vote
1answer
23 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
58 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 ...
1
vote
1answer
37 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} ...
7
votes
1answer
124 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 ...
5
votes
1answer
155 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} ...
7
votes
2answers
263 views

QR-code from jobname

I would like to print a qr-code in a LaTeX documnet. The info to the \qrcode command of qrcode package would come from the file name by the varsfromjobname package. But it does not work for me: ...
7
votes
2answers
111 views

Why \newlength is not profiled as \newcommand?

While commands are defined and set in one step with \newcommand, lengths need two steps for this: \newlength and then \setlength. Because \newlength{\foo}{1cm} would be easier than ...
2
votes
1answer
61 views

\newcommand doesn't work with \section and \chapter

I have a newcommand defined as follows: \newcommand{\met}{\cancel{\it{E}}_{T}} When I try to place it into a \section like this: \chapter{\met} I get error messages like this: ! Undefined ...
0
votes
0answers
26 views

What is the meaning of the “at mark” @, also called “Klammeraffe”, in LaTeX commands? [duplicate]

I have seen the "at symbol" on several occasions, used in connection with LaTeX macros, often as part of command names. Does this symbol have a special significance in LaTeX, or is it just a ...
2
votes
0answers
51 views

How to redefine the chapter like the following?

I have a newcommand to redefine chapter. \newcommand{\Chapter}[1]{ \clearpage % \noindent \refstepcounter{chapter} \begin{center} \dsp{CHAPTER\space\thechapter\\} \vspace{10pt} ...
1
vote
1answer
52 views

A command for making a string of characters [duplicate]

How can I make a command (or is there an existing one?) which takes two arguments: 1) character type 2) N (count) and puts N number of characters side by side? \newcommand{\foo}[2] { % sample: ...
11
votes
3answers
407 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 ...
2
votes
1answer
68 views

Macro for tables that take as arguments the column and row dimensions

I am working with tabulars formatted in a consistent way. Sometimes the tables are 3X3, 3X4, 4X4 etc nXm in general. As it is I have a macro for each of these tables: \matrixIIIC, \matrixIIID etc. Is ...
1
vote
3answers
75 views

Font size macro only works once in the document

I am writing a paper where HI comes up a lot. I need the capitalized "I" to be slightly smaller than the "H" so I have been doing this: H\small{I} However this only works in the first instance of my ...
6
votes
1answer
162 views

Correct usage of the LaTeX \newcounter and associated commands?

Previously I had a question about the \newcount command. I was then led to consider the \newcounter command instead, that does allow the use of digits in counter names. Accordingly, I have modified ...
2
votes
1answer
58 views

Workaround that allows the use of digits as part of counter names?

I tried to define indexed counters, such as x1, x2, . . . etc, by defining them like this : \newcount\x1, \newcount\x2, . . . etc, but it didn't work. Is there a workaround for this in TeX or LaTeX ? ...
0
votes
0answers
27 views

What is the difference between \number and \the ? No.2 [duplicate]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Here is the example tex-file that illustrates use of \number and \the . %% ...
6
votes
1answer
178 views

What is the difference between \number and \the?

I am trying to learn more about macro programming - if that's the right word - in TeX and LaTeX. I began by defining a quantity I called Sum : \newcount\Sum. I then wrote \Sum=0. Then I did some ...
1
vote
1answer
48 views

How to remove unwanted asterisk that appears in margin when multibib is used with custom Section command?

Background - I'm modifying a fairly well documented LaTex CV to build my own. All works well, till I tried to add publications using the multibib package (using this answer in Tex.SE). When I ...
3
votes
1answer
81 views

How to append colored text to a macro in a loop?

I'm trying to append a couple of colored numbers to a macro in a loop. That is, I'm hoping to achieve the following but with a loop: \documentclass{article} \usepackage{tikz} \colorlet{color1}{red} ...
2
votes
1answer
63 views

Error when using empheq in a newcommand

I have just started working with the package empheq as a way to create a box around equations. I would like to create a pair of short new commands for entering and exiting the empheq environment, but ...
4
votes
1answer
46 views

Repetitive reports

I have a report that uses the same number a lot of times throught the text (money reference $). There`s a way to automate this refference so I update only the "main field"? Thanks Example: pg. 1 = ...
2
votes
1answer
113 views

Overwrite \def to check if the command exists?

LyX supports math-macros, but sadly when passed to the latex processor, they are defined by a \def rather than a newcommand. I have found overwriting commands (e.g. using \def\v{\mathbf{v}}) to ...
3
votes
1answer
77 views

linebreak and pagebreak wherever I want with justified margins

I am looking for two commands: \mylinebreak \mypagebreak The first is supposed to break a line at the very position where the command is set and make the previous line justified (and not ...
9
votes
3answers
169 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 ...
3
votes
1answer
99 views

Using \newcommand, \input and \includegraphics

I am writing a paper that includes simulation results from performing a number of trials of an experiment. Each of the output figures (.pdfs) I produce includes the number of trials in the filename ...
3
votes
3answers
168 views

Check macro argument has correct format

I have a macro which will read in arguments in date format e.g. {2012-11-08} \usepackage{datetime} \def\customdate#1#2#3#4-#5-#6\relax{% \shortmonthname[#5] '#3#4% } However, in some instances I ...
3
votes
2answers
49 views

Inserting macros mixed with static options

I've been trying on and off for a few days to wrap my head around the following. I want to insert options defined in a macro alongside options statically defined into the option list of another macro. ...
5
votes
1answer
44 views

macro value can not be updated in tabular with multirow columns

I am writing a command \newrow to generate one row in a longtable. The problem is that the tabular environment here can not see the value of \subColWid (output is 0pt). This occurs only when multirow ...
1
vote
0answers
43 views

macro for glossaries counter

I want custom my glossaries, and specially I want to have something like My glossary entry, its signification (see p. 1), if this entry mentioned only once or My glossary entry, its signification ...
1
vote
1answer
103 views

Opinions: Circuit_macros or circuitikz ? what is better? [closed]

I'd gladly read your opinions on Circuit_macros pros and cons, as well as yours on circuitikz. Gives the macro more variables to play with? Is the circuitikz language easier? Macro use seems far more ...
0
votes
0answers
61 views

Ignoring parts of text inside macro

Consider the following code: \documentclass{book} \usepackage{pgffor} \begin{document} \newcommand\containers{ \cont{aaa{\bf don't xstring me}aaa} \cont{bbb\large bbb} ...
2
votes
1answer
63 views

renewcommand the chapter in chinese problem

I move code from Miktex into Texlive. But I get errors: Run in Xelatex ! Undefined control sequence. \chaptername ->第\CJKnumber {\thechapter }章 l.33 \chapter{绪论} ...
2
votes
1answer
68 views

marginpar in a macro steal the bullet of itemized list

I have an odd (to me) problem involving an itemize environment and \marginpar{}. The problem is illustrated in the following document: \documentclass{article} ...
0
votes
1answer
34 views

Problem with \newcommand{\nal}{\end{align*}} [duplicate]

Why do these newcommands result in error when used? \newcommand{\bal}{\begin{align*}} \newcommand{\nal}{\end{align*}}
2
votes
2answers
63 views

What is the difference between a package and a template in LaTeX?

I was looking at the post How to disable automatic indentation on new paragraphs? and the given comments. It was suggested that I go to Ask Question. Which is what I am doing now. Somebody was ...
4
votes
2answers
58 views

Trouble using convertchar and thestring inside a LaTeX command or table

I'm trying to generate page references inside a command that defines a row of a table, with the name of the label being referenced generated as a result of some string maniupulation using ...
6
votes
4answers
113 views

Using MakeLowercase and StrSubstitute together

I'm using LaTeX and have a string that I want to remove underscores from, and convert to lower case (in either order). The individual steps work: \MakeLowercase{AB\_CD} \StrSubstitute{AB\_CD}{\_}{} ...
1
vote
0answers
19 views

Defining New Command with regular text inside math mode (Notation) [duplicate]

I would like to denote the volume of a lattice as vol $L$ and the determinant similarly as det $L$, so that the words "vol" and "det" are in the normal/regular text format but the L is in mathmode. ...
3
votes
3answers
127 views

How to use a macro to store the default pgfplot properties

I have some default settings for my pgfplots plots, such as xlabel, ylabel, width and so on. Since I have a large number of such plots and don't want to repeat all the properties, I want to store them ...
4
votes
2answers
132 views

Problem with defined macro and blank lines

I am using the following command to color some text: {\color{NavyBlue} Text Here! } Because I used it frequently I created this macro: \def\cl#1{{\color{NavyBlue}{#1}}} When I am using the ...
1
vote
1answer
52 views

Automatically enclose \glt line from gb4e in \enquote{}

How can I automatically enclose the \glt (\trans) line in gb4e's interlinear glosses in context-aware quotation marks with \enquote{} from csquotes? \documentclass{article} ...
4
votes
1answer
74 views

Probsoln customization of solution environment (set as marginpar)

I'm using probsoln, and I want to put the solution as a marginpar and with footnotesize. Please look at the MWE below. Writelatex won't compile, spitting out LaTeX Error: \begin{solutionnew} on ...
0
votes
1answer
60 views

Variable number of arguments for \newcommand

I use the following command to write my matrix variables \newcommand{\mymat}[3]{\ensuremath{\mathbf{#1}^{#2}_{#3}}} Thus #1 is the matrix variable, #2 is the superscript and #3 is the subscript. ...
2
votes
1answer
89 views

PGFPLOTS: How To Put \addplot boxplot prepared Inside Macro Definition

I have a need to wrap the `\addplot [boxplot prepared]' inside a macro to greatly save typing. It seems simple enough, but the devil is in the details with macro expansion issues. Is this doable given ...