{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
1answer
53 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 ...
1
vote
1answer
34 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 ...
1
vote
0answers
22 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 ...
1
vote
1answer
46 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 ...
4
votes
1answer
58 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: ...
0
votes
0answers
45 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
29 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 ...
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
44 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 ...
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 ...
1
vote
1answer
27 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
4answers
91 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 ...
3
votes
1answer
24 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 ...
3
votes
1answer
69 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 ...
5
votes
1answer
29 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 := ...
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 ...
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 ...
4
votes
1answer
60 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
116 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
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 ...
0
votes
1answer
47 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
65 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
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 ...
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} ...
7
votes
1answer
83 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
128 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
244 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
106 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
48 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
16 views

Macro that feeds its argument to an environment that changes the catcodes

Suppose an environment that reads its contents with changed catcodes (verbatim, CJK, etc). I want to write a macro that invokes this environment on its single apparent argument. The argument is ...
0
votes
0answers
23 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
44 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
47 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
314 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
56 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
56 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
132 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
56 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 . %% ...
5
votes
1answer
153 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
31 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
68 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
51 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 ...
3
votes
1answer
43 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
75 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
40 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 ...
3
votes
1answer
32 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
69 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 ...