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

How to apply a macro to each row of a table

This is similar to the question about cells, but with whole rows, and hopefully will help me to implement an answer to this question. Given a macro \RowMacro, how can I define the mytable environment ...
1
vote
2answers
36 views

newcommand for $\frac{\mathrm{d}^4q}{\left(2\pi\right)^4}$

Can you give any hints on how to define a new command that writes $\frac{\mathrm{d}^4q}{\left(2\pi\right)^4}$ with the options that one can write $p$ instead of $q$ (say) and also if one could ...
5
votes
1answer
39 views

Formatting a comma separated list of values

I'm creating a set of mathematics worksheets, and I'd like to have an upside down "answer key" below a set of enumerated questions. Here is what I have at the moment: \usepackage{graphicx} Answers: ...
5
votes
1answer
41 views

Use \LetLtxMacro with a \Macro* (starred variant)

If I use: \LetLtxMacro{\MacroToUse}{\FormatText} then using \MacroToUse invokes \FormatText exactly as desired. But, how do use this construct to invoke \FormatText*? The MWE below yields: but ...
7
votes
1answer
48 views

Purpose of \do@noligs in LaTeX verbatim environment

I'm trying to figure out how the verbatim environment works. In the basic LaTeX file latex.ltx I find the following definition (line 4037): ...
2
votes
2answers
37 views

Multi-line text retrieved from file via \input, within a newcommand declaration, passing newly declared command as argument of standard letter class

I have put together a minimum working example consisting of a number of files mwe.tex % instance of personal letter address.tex % full address of individual being addressed in mwe.tex ...
1
vote
0answers
36 views

Define tikz node based on pagenodes

I want to define a tikz node called current grid area based on the nodes defined by the tikzpagenodes package. This node is a rectangle that contains the 4 nodes defined in the package; current page ...
15
votes
3answers
136 views

Defining Extensible macros

Question: For a macro that has only one parameter, are there any issues with defining it as follows: \NewDocumentCommand{\MyMacro}{% s% #1 = starred variant (*** unused as of yet ...
4
votes
1answer
31 views

Use of \cals doesn't match its definition \calscommand

The following minimal working example employs a cals table in the document environment and works fine: \documentclass{article} %document encoding \usepackage[utf8]{inputenc} %geometry ...
5
votes
2answers
50 views

Define a command for vectors, boldface letters, but not numbers

The purpose for this would be to leave scripts out of the equation. For example, \renewcommand{\vec}[1]{\ensuremath{\mathbf{#1}}} ... \vec{x_0} would print the 0 as boldface, too. I know I can ...
17
votes
2answers
214 views

Difficulty with macro expansion (updated)

I'm not getting the output I want from my LaTeX code, and I think the problem is that I'm not expanding things at the right times. Code \documentclass{article} \usepackage{tikz} ...
5
votes
3answers
48 views

Create an array of variables with string keys

I'd like to have a macro where I can insert a key as argument and get a value which I have defined before. This should be similar to Create an array of variables but with strings/text instead of ...
4
votes
4answers
83 views

Defining a new environment extending a verbatim environment

Why is it not possible to define a new environment that extends a verbatim environment? Consider, e.g.: \documentclass{article} \newenvironment{myverbatim}{\tiny\begin{verbatim}}{\end{verbatim}} ...
4
votes
3answers
36 views

Using variables in a command results in ! Argument of \reserved@a has an extra }

I want to define a command, which separates a string an later adds a different \href to the first part, than to the second (e.g. \qname{foaf:Person}). But the code as I have it doesn't work, I get ! ...
6
votes
1answer
42 views

amstex: operator definition error

I can't understand why the following code give me an error \input amstex.tex $\mathop{\rm arctg}(x)$ \bye Thus, the input does not work with my macros that include the use of \rm, \mathop, etc., ...
4
votes
1answer
61 views

Numbers in \newcommand not working

I am trying to use the chosen solution shown here, for being able to use numbers in the alias I need for \newcommand. (That one is not able to use numbers in the alias directly strikes me as ... well, ...
10
votes
1answer
52 views

extrarowheight vs arraystretch

What's the difference between these two in a table environment? I've seen they cause somewhat the same result, but I have no idea what is the difference, except that arraystretch is used in a scale ...
7
votes
1answer
59 views

String Comparison with a \protected\def

I am using a \protected\def as that solved an earlier issue of mine. I need to compare this value of the token to see if it is initialized to the same value as the \protected\def in different ways. ...
2
votes
2answers
60 views

Undefined control sequence \pgfmath@

Why does the following code give me this error message? Error ERROR: Undefined control sequence. --- TeX said --- \pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@ l.28 \draw ...
3
votes
1answer
58 views

A list of pairs in pgfkeys

Having learnt a lot about the pgfkeys package as a result of my last question, I'm now trying to do some more adventurous things. Let's say I have a command called \blob, whose value is the ...
7
votes
2answers
157 views

Stupid error caused by doing stupid things

When I was writing my thesis I wrote the following two commands which I found useful (and still do). They are both ways of defining other commands. \usepackage{ifthen} \makeatletter \def\optional ...
18
votes
5answers
228 views

How retrieve items in a list of words by number?

I'm working on a character sheet for the Fate RPG, which rates its skills with a numerical scale that corresponds to an adjective scale. I've been trying to write a macro that will take \skillAdj{4} ...
8
votes
2answers
92 views

What does \secdef do?

The definition of the chapter command in KOMA-class scrbook is: \newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi \thispagestyle{\chapterpagestyle}% \global\@topnum\z@ ...
8
votes
1answer
112 views

How to disable \renewcommand

I've got a custom class derived from report. I defined some standard commands inside of it to reflect its specific, so they look like: \newcommand\contentsname{Custom Content} ...
3
votes
0answers
75 views

XML or other markup to LaTeX?

In my university project I am doing software testing - planning, implementation, evaulation. All test documents have the format: General information Test categories Test cases Test implementation ...
3
votes
1answer
50 views

Setting initial value of a storage macro

When I create a "storage macro" I often initialize it to be empty with \newcommand{\@mymacro}{} \newcommand{\mymacro}[1]{\renewcommand{\@mymacro}{#1}} Instead of initializing it to empty I could do ...
2
votes
1answer
26 views

using a restatable before it is stated

This question is related to the question at Recalling a theorem, which uses the thmtools and thm-restate packages and the restatable environment to define a theorem that can be re-stated later on. Is ...
3
votes
2answers
53 views

Section command with default spaces between title and rule

Ho can I make a section command that have the same spaces between the \titlerule and the title of the original \section command? The overall look must be equal to the original \section command. So, Is ...
9
votes
4answers
286 views

Macros: MS Word vs. TeX & friends

This is a follow-up question to How to convert TeX-illiterate coworkers to LaTeX?. To better demonstrate the power of TeX & friends and dismiss the competition (e.g. MS Word, Open Office), I need ...
3
votes
1answer
46 views

How can by macro as parameter of other macro?

\StrPosition{AQ2 K863 1065 J1065}{ } give 4 \StrMid{AQ2 K863 1065 J1065}{1}{4} give AQ2 \StrMid{AQ2 K863 1065 J1065}{1}{\StrPosition{AQ2 K863 1065 J1065}{ } } i want AQ2 but give error message.
6
votes
1answer
38 views

Count words separated with comma in macro

I need to count number of words in a macro defined as follow: \def\columnNames{MATRIX, METHODA, METHODB} I manually set number of words as follow: \pgfmathsetmacro\numberOfColumns{3} I need an ...
11
votes
2answers
73 views

Patching arguments inside a macro

Consider the following example of a patch using etoolbox and a dummy macro \abc: \documentclass{article} \usepackage{etoolbox}% http://ctan.org/pkg/etoolbox \newcommand{\abc}[2]{#1\ #2}% Magic ...
2
votes
1answer
46 views

Command to write MIMO configurations

I want to write something like MIMO (multiple-input and multiple-output) configuration 2 x 2, 2 x 4, etc. and be consistent all over the document. For now I have defined a command to do that as I put ...
3
votes
1answer
30 views

parametrized variable with if else statements

I need to create parametrized variable \mycolor like in this example. The variable \mycolor defined colour based on an argument. I need to compare #1 with values 1, 2 and so forth, but how to use if ...
7
votes
2answers
57 views

Setting an “attribute” for Theorem to be accessed later

I am writing a math paper with a large number of theorems. I'm looking to have a table summarizing my results, and I'd love it if the table could be generated automatically from my paper. I' looking ...
3
votes
1answer
62 views

To-do-notes in separate TeX File, but without \listoftodo in main doc

I am using the todonotes package and have three requirements, the first two which the MWE already does: Obtain a list of todo notes in a separate auxiliary file. This can easily be obtained via the ...
3
votes
2answers
62 views

Changing line spacing within a new command

I have a command written as follows: \documentclass[12pt]{book} \usepackage{setspace} \newcommand{\statshyp}[2]{\noindent \hangindent=1cm \hangafter=0 \begin{singlespace*} \textbf{#1}: \emph{#2} ...
1
vote
1answer
83 views

some \newcommand instructions not working

I have created some new short command using \newcommand in the following example: \documentclass[12pt,twoside,a4paper]{book} \usepackage{enumerate,amsmath} \newcommand{\ba}{\begin{array}} ...
1
vote
1answer
23 views

Error in PSTricks in circuit macros

I am trying the same way to use circuit macros through the example from Mr. Peter Jan Randewijk (http://staff.ee.sun.ac.za/pjrandewijk/wiki/index.php/M4_Circuit_Macros). I have installed M4 support as ...
4
votes
3answers
131 views

Arguments to Commands: […] vs {…}

Perhaps this is something that has been answered before, but a cursory search didn't turn anything up. Is there any logic to how commands take arguments? Some things want the arguments to the ...
11
votes
1answer
53 views

Simple way to switch inline asymptote figures on and off

I use the inline asymptote environment \begin{asy} to draw a lot of the figures in my papers. To those not familiar with asymptote, the asymptote package creates *.asy files for each of the asy ...
3
votes
0answers
55 views

Can I define \supercite to act as \cite?

I have a document using supercite and it works fine, but I am now using a different set of packages and cite works better. So rather than me have to change them all, is there a way I can define ...
6
votes
1answer
54 views

Temporarily undefining a “starred” command

I would like to temporarily undefine a command. The reason for this is that I need to use a specific class file which defines the equation* using \@namedef and I would also really like to use the ...
2
votes
1answer
50 views

Turning working code into macro causes “Missing number, treated as zero — \let”

Here's a minimal working example (MWE): \documentclass{scrartcl} \usepackage{listings} \begin{document} \noindent\minipage[t]{0.45\linewidth} \lstlisting foo \endlstlisting \endminipage \qquad ...
2
votes
1answer
71 views

Compilation fails with “! Missing \endcsname inserted.”

Hi I've got a strange problem. I've defined a new command to print Linux commands line in the document: \documentclass[12pt,a4paper]{article} \usepackage{listings} \newcommand{\shellcmd}[1] { ...
2
votes
1answer
57 views

How to use pgfkeys' /.style args handler without knowing the exact form of the input?

I would like to be able to create a command (using pgfkeys) that can take inputs that are of a limited set of forms, and for which certain pieces will come from a limited set of values. More ...
3
votes
1answer
104 views

How to run LaTeX and lilypond-book in one command?

I was wondering if there was any command which would let me create a PDF from a LyTeX source in one step. Currently, I am first executing lilypond-book: lilypond-book --latex-program=pdflatex --pdf ...
1
vote
1answer
68 views

Command \* already defined … see p.192 of the manual

My code had: \newtheorem*{theI}{Thesis I} And it gives me the error: Command \* already defined. Or name \end... illegal, see p.192 of the manual. 1.16 \newtheorem*{theI}{ ...
4
votes
1answer
39 views

Expanding a macro into a long list for use with pgfplotstable

Failing again to get macros to work. I have the following M(n)WE \documentclass[10pt]{article} \usepackage{pgfplotstable} \begin{document} \xdef\mydef{ \foreach \a/\b in ...
4
votes
2answers
44 views

Package xparse \SplitList last token

I need to create a macro to render lists with a variable number of arguments (1+), e.g. \mylist{1,2,3} should expand to $\tilde{1}$--$\tilde{2}$--$\tilde{3}$. I'm trying to use xparse and \SplitList, ...

1 2 3 4 5 32