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

6
votes
1answer
64 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
38 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
137 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
162 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
272 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
117 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
71 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
56 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
53 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
428 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
75 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
83 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
171 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
61 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
28 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
194 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
50 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
85 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
73 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
143 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
84 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
175 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
112 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
174 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
50 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
47 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
48 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
115 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
62 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
83 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
73 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
35 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
69 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
64 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
122 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
137 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
138 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
59 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
86 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
66 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
114 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 ...
6
votes
1answer
37 views

Value of \def specified via command line not being properly recognized

I am having difficulty understanding why defining a macro on the command line is being treated differently than if it is specified in the file. The MWE below allows \FormattingMode to be set to Print ...
1
vote
1answer
85 views

pgfplots: Optional graph range arguments in a macro

I defined a macro that inserts a plot that I can re-use the same graph style in multiple places. Mine actually loads data from a file, but a similar MWE looks like: \newcommand{\drawGraph}[1]{ ...
4
votes
1answer
70 views

Problem grouping environments

Below are two examples. The first one works fine, no errors no warnings, but on trying to build a doc from the latter, I get a heap of errors. Working: \documentclass[]{article} \usepackage{environ} ...
3
votes
2answers
71 views

How to divide underline with ULEM package?

In some Chinese books, proper nouns were underlined uncontinuously. How to divide underline with ULEM package, as in the first pic? I changed the ulem package, and want to seperate some words, ...
6
votes
2answers
145 views

Trying to convert Hrs:Mins to Mins

I am having a bit of trouble trying to convert a time format from Hours:Minutes for instance 12:05 into 12*60+5 = 725, ie I would like to use 725 as a number of minutes. I am already using the number ...
3
votes
1answer
47 views

Pass blank as argument to a command

How can I pass a blank to this command \newcommand{\iam}[1][happy]{I am #1.} so that I get this result I am . Note: My actual command operates in the math mode, so the space between "am" and "." ...