{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
1answer
20 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 ...
1
vote
2answers
31 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 ...
7
votes
1answer
41 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): ...
1
vote
0answers
35 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 ...
11
votes
1answer
985 views

Alternatives to $\backslash$

Background Instead of marking up the text with bold or emphasis, I read (and agree) that it is better to define a command, or environment, that describes the content. Then apply text formatting ...
28
votes
7answers
3k views

What is the recommended way to assign a value to a variable and retrieve it for later use?

What is the recommended way to define a variable inside a document and retrieve its value later? I've googled several different solutions, usually about ~10 lines long. I was wondering, that there ...
15
votes
3answers
126 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 ...
16
votes
2answers
196 views

Difficulty with macro expansion (updated)

Update. I have another problem that is so closely related to this one that I decided not to raise it as a new question, but instead to edit this one. Although Heiko's answer has explained how to fix ...
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 ...
4
votes
4answers
80 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
34 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 ! ...
5
votes
3answers
47 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 ...
84
votes
4answers
2k views

What is the use of percent signs (%) at the end of lines?

I see that the code in many packages and examples contains percent signs % at the end of (many) lines. What are they used for? Do they affect the parsing of those lines?
14
votes
3answers
2k views

Is there any way to generate custom errors/warnings in LaTeX?

I want something like \ifmmode\else\GenerateWarning{The command \backslash uzuka is supported only in math mode.}\fi, which is supposed to generate a warning "The command \uzuka is supported only in ...
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, ...
3
votes
1answer
57 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 ...
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 ...
18
votes
5answers
226 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} ...
7
votes
2answers
155 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 ...
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
111 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} ...
7
votes
1answer
254 views

Keeping the names of things consistent in LyX.

I'm documenting a software project using LyX and many of the "things" (classes, processes, etc.) that I'm describing don't yet have good names. As my understanding of these things improves, I want to ...
3
votes
0answers
74 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 ...
4
votes
1answer
90 views

Create command to inline an image in a question?

How to create a command to can insert the image in a line of text question? Since I have a lot of question types made True/False, Short Answer types, Multiple choice, etc. I want the command to be ...
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
52 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 ...
10
votes
1answer
5k views

What is the purpose of \protect? [duplicate]

Possible Duplicate: What is the difference between Fragile and Robust commands? I've never understood the purpose of the command \protect? When and why should it be used?
12
votes
3answers
395 views

Adding a list of bios to the book class

I am busy with a document where I need to add an Appendix with a list of names and short biographies (about a paragraph each). I would be happier if I can do that as I describe the person in the ...
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.
12
votes
2answers
302 views

New command with optional argument being first argument [duplicate]

I know I can create a new command with an optional parameter with \newcommand{\mycommand}[2][Hello]{\textbf{#1} #2} I would like to have the command such that there is an optional parameter which ...
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
2answers
61 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} ...
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 ...
22
votes
5answers
729 views

How to find out where a macro is defined?

Using \@ifdefined (in LaTeX), we can check whether a command is defined. Using \meaning, we can get the definition of a command. Can we also get information about where a command was defined? For ...
6
votes
2answers
96 views

Custom verbatim that sets all spaces (“ ”) as visible spaces (“␣”) that can line-break

It makes sense to typeset code in a monospaced font. Sometimes such code needs to be embedded in a paragraph context, and then it will be useful to allow it to linebreak. In order to visualize spaces ...
1
vote
1answer
82 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}} ...
12
votes
2answers
187 views

Search for most frequently occurring patterns in text (to replace them by macros)

Are there any ready available tools for searching the most frequently occurring text patterns (word combinations, phrases) in the text you work on, so to give ideas, which ones to replace by short ...
1
vote
1answer
22 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 ...
5
votes
3answers
198 views

Online references for creating advanced macros?

I am looking for online references for creating advanced macros for LaTeX.

1 2 3 4 5 32