{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
192 views

Using Hashtag in macro

I had a problem putting the column headers in bold (in a table of course) using pgfplotstable. You can see the problem here I found a way to work arround that. It isn't generic as I wanted it to be, ...
2
votes
2answers
341 views

How to define new command for commands like \frac{} or \int{}^{}?

We know that we could define a new command for boldfaced or calligraphic C, for example I can define \newcommand{\Cx}{\mathbb{C}}, which will produce the boldfaced C, i.e. $\mathbb{C}$ for me. But how ...
5
votes
3answers
148 views

Metacommand for commands that dynamically select a parameter?

Original question I would like to create a metacommand for creating new projection commands. Specifically, \newproj{\cmd}{<n>}{<m>} should create \cmd as a new command of <n> ...
6
votes
2answers
261 views

How to use variables inside a command when generating a table?

I'm not sure about the question, since I do not really understand why it fails. I tend to use commands to generate my tables, and when I use the #1 style of accessing the arguments it works. But now ...
3
votes
1answer
147 views

Is it possible to redefine \alpha this way?

I was thinking about doing something crazy, namely, I want to define a "newcommand" by \renewcommand{\alpha}{\ensuremath{\alpha}} so that later in text mode I can just do \alpha instead of $\alpha$ ...
16
votes
6answers
499 views

A new environment to decide dynamically which commands to run?

I am having some user defined commands defined and used in my latex document. I need a way to check whether any of the commands is used. I want to make decisions based on the argument used in the ...
0
votes
0answers
37 views

Create two small box after text? [duplicate]

how should i declare a command for two small boxes after text in every line? based from this link Create a two column static small box. I need to remove the automatic printing of its numbers. What ...
0
votes
2answers
215 views

Creating a command similar to \vrule

Upon trying to create a new border similar to the \vrule command, I have the following: \documentclass{article} \usepackage{xcolor,framed,lipsum} \def\bulletfill{\vbox to ...
4
votes
3answers
242 views

How are space tokens and empty lines processed by long commands (as their potential arguments)?

How are spaces and empty lines processed by long commands (i.e., those that do not accept paragraph breaks inside)? Are there different space tokens aside from " " and an empty line? It appears that ...
7
votes
2answers
128 views

Using a character as a macro within another macro in (La)TeX

Goal: What I would like to do is to allow _ and ^ to be used to generate sub and superscripts in text mode only within a specific macro. I know that I can make _ and ^ active throughout the document, ...
21
votes
3answers
335 views

If I redefine a command that has a starred variant, will that always disable the starred variant?

If I redefine a command that has a starred variant, will this always effectively disable the starred variant, as a side effect of redefining the unstarred variant? A related question: Do starred ...
2
votes
0answers
160 views

How to prevent continuation to the next page? [closed]

i learned of the samepage environment based from this link Unbreakable block so i tried it on my case but i think this isn't what I am looking for. My problem is: with the exam class, i have created a ...
7
votes
1answer
249 views

How do I typeset the name of this site in (La)TeX?

How do I typeset the name of this site (TeX.SE) in (La)TeX? And, what is the name of this site? I thought TeX - LaTeX was technically correct, but another user suggested something similar to \TeX{} ...
2
votes
1answer
198 views

Automatically add theorems to index and label them

In another question (Remove math from command parameter to get only the letters) this command was elaborated to have an optional argument for sorting purposes within the index \documentclass{article} ...
5
votes
3answers
143 views

Remove math from command parameter to get only the letters

I use a little command, which prints new defined terms in bold, adds a label and adds them to the index. \newcommand*{\defined}[1]{{\bf #1}\label{#1}\index{#1}} Now if I do \defined{$G$-invariant} ...
6
votes
3answers
310 views

Aligning image and text in new command in TikZ

As a Teaching Assistant for a class, I am trying to draw a seating chart for the professor. The seating chart will have a photo of each student, the student's name, and where the student is sitting in ...
4
votes
1answer
100 views

automatic nomenclature breaks with subfigure

I am using the method recommended in List of symbols/abbreviations and macros to automatically generate an entry to the nomenclature (nomencl package) when I first use a command, i.e. ...
6
votes
1answer
86 views

\newcommand with adjustable size

I'm soon going to take Live-notes of a course where Tensors are commonly used. Tensors consist of a Letter, say T, with numerous sub-and superscripts. Generally, a tensor could look like ...
10
votes
1answer
403 views

Interaction of \boldmath and \not

It seems that using \boldmath (or \bm) along with the \not does not quite work so well. Here is an example using \not\subseteq and \not\le where the line representing negation does not stretch ...
3
votes
1answer
115 views

Create command not using adjustbox package for inserting image

I am creating a test question using exam.cls and I think it would be different if i will include image in the question. But i dont really know how should I insert it. i found a solution code that ...
4
votes
1answer
113 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 ...
4
votes
2answers
137 views

Why can't I insert a blank line in this code?

In the code below, everything is OK until I insert a blank line instead of one of the \\'s. Upon inserting a blank line, I'll get some errors. How can I get rid of these errors? ...
26
votes
3answers
920 views

Always use \NewDocumentCommand instead of \newcommand?

Are compelling reasons to stick with \newcommand or should one always use \NewDocumentCommand instead, even when not using any of the additional features offered by xparse? In addition and more ...
7
votes
1answer
951 views

cool package derivative and eulervm \mathbold fails with 'Missing control sequence inserted.'

Compiling \documentclass{article} \usepackage{cool} \usepackage{eulervm} \begin{document} $\D{a}{T}$ $\pderiv{a}{T}$ $\mathbold{T}$ $\D{a}{\mathbold{T}}$ $\pderiv{a}{\mathbold{T}}$ ...
3
votes
1answer
213 views

How do I create the following macros?

I would like to define the following macros. \newcommand{\NC}{\ensuremath{\mathbf{NC}}} \newcommand{\NC}[1]{\ensuremath{\mathbf{NC^{#1}}}} But LaTeX complains that \NC is already defined. So, I ...
4
votes
2answers
266 views

Toggle visibility of solutions in LaTeX output for exams

So I have my own layout for my exams based on scrartcl and to prevent anomalies during some changes I want to have only one file per exam which holds both questions/excercises and solutions. Yet I ...
5
votes
2answers
112 views

passing current content of commands to a macro

I am sorry for this is probably a current question with a well known answer, but I was not able to google it out. I am trying to build a macro adding content step by step; at every step I need to ...
2
votes
1answer
109 views

Biblatex custom cite macro

I don't really understand how to use macros, but this would be a good way to learn. Currently, I simply use \cite, which prints Author, Year. When I have this in a sentence, I want the year to be in ...
8
votes
1answer
156 views

Which commands exist to define new commands?

Which commands are there that one can use to define new commands in (La)TeX? There are: \let, \def, \[re]newcommand[*], \DeclareRobustCommand[*], and ...? (And I've seen things like ...
9
votes
1answer
230 views

how to redefine \begin{align*} … \end{align*} to \begin{eqnarray*} … \end{eqnarray*}

Scientific word insists in generating displayed math using \begin{align*} ... \end{align*} and htlatex has a bug in that it does not generate bit mapped images in this case. The fix that I found ...
16
votes
4answers
549 views

Do starred commands eat up space after them?

Do starred commands eat up spaces after them, like unstarred ones do? That is, is \somecommand* nextword equivalent to \somecommand*nextword? And: Does it depend on the particular way a starred ...
7
votes
1answer
75 views

Is there any reason against changing the starredness of a command upon redefinition?

If an original definition of a command used \newcommand, is there an obligation for me to redefine it with \renewcommand instead of \renewcommand*? If an original definition of a command used ...
11
votes
2answers
135 views

Is there any reason to define a zero-argument macro using a starred defining command?

Is there any reason to define a 0-argument (read: zero-argument) macro with a starred command (\newcommand* instead of \newcommand or \DeclareRobustCommand* instead of \DeclareRobustCommand)? After ...
0
votes
0answers
67 views

True `macros' in (La)TeX [duplicate]

When using \newcommand and the like, LaTeX seems to create a new box for the content (I'm probably observing things wrong). For example, I have \newcommand{\p}[1]{\ensuremath{\left(#1\right)}} in my ...
0
votes
1answer
128 views

Expansion of single line vs multiple line gather

As described in Multiple split equations I want to create an equation environment that inserts aligned and lets me split equations with \n. The solution I found there is a bit hackish I guess, but ...
5
votes
3answers
491 views

\includegraphics optional argument not resolved if macro

\documentclass[a4paper,10pt,twoside]{book} \usepackage[demo]{graphicx} \begin{document} \newcommand{\scalefactor}{scale = 0.25} \begin{figure}[!ht] \centering %Next line does not work ...
4
votes
2answers
631 views

Line break (continuation) for commands (options, arguments)

How to do proper line breaking (continuation) for commands, i.e. their options and/or their arguments? For example, in order to transform this: \usepackage[top=1.0cm, bottom=1.0cm, left=1.0cm, ...
2
votes
1answer
100 views

How to put R code into a parameter of a newcommand?

I would like to put R code into a parameter of a newcommand in LaTeX. To do it, I make the following: %Define the newcommand: \newcommand\solution[1]{\sf #1} %Then, after the \begin{document}, I ...
7
votes
1answer
187 views

Generating code examples

I would like to make a table showing some custom commands that I have defined. It would be nice if I could do something like the following. \documentclass{article} ...
1
vote
1answer
137 views

Problem if csv list is stored in macro for later use with \forcsvlist

I need to store a csv list for later use in the end code part of an environment. Can somebody explain me what's going wrong in the following example? \documentclass{article} \usepackage{etoolbox} ...
26
votes
3answers
688 views

When is it better to use \par than \endgraf?

Just yesterday I had to patch a package file (changing the description to indicate that the file had changed) to replace some \par to \endgraf because the code had bad interactions with non-\long ...
5
votes
1answer
173 views

Underscore should not force mathmode in macro

When trying to color words in arabic (transliteration), LaTeX wants me to be in mathmode (Missing $ inserted.), as there is an underscore in the transliteration. This is of course completely wrong as ...
1
vote
1answer
202 views

Is there a \newcommand manager program?

I type my latex document with gedit. I use a lot of macro to facilitates typesettings. I put all of them just after the begin{document} tag. For a homework question says, I use at least 20 macros. For ...
12
votes
2answers
2k views

What does \relax do? [duplicate]

Possible Duplicate: How can I speed up LaTeX compilation? What is the difference between \relax and {}? The title suggest the question. On and off, I see macros here in TeX.SE and I see ...
6
votes
1answer
368 views

How to define macro containing TikZ \coordinate

I am trying to create a macro to calculate the center of a shape. Consider the following code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \newcommand{\getcellcent}[4]{ ...
7
votes
3answers
201 views

How to define a new command for guillemets marks [duplicate]

Possible Duplicate: babel shorthand "| doesn’t work in macros I would like to define a new command for guillemets marks. I know how to obtain them in LaTeX and those I would like to ...
5
votes
1answer
1k views

force section and subsection to capital letters

hi Im trying to renew the section cmd to make all sections in capitals. i have tried stuff like \newcommand{\tmpsection}[1]{} \let\tmpsection=\section ...
6
votes
3answers
168 views

PGF keys error with key filter for keys containing \par

I am trying to use pgfkeys to store some text for use later. The end goal is to use a key filter to process options first and then apply them to text before it is stored. In the MWE below, if it try ...
1
vote
1answer
127 views

Automatic subscript command

I am working on a document that has a lot of subscripts. I am getting really tired typing the _. Is there a way to do the following: Everytime I want $v_1$, I just want to type in v1. Or b1 produces ...
2
votes
2answers
180 views

Error with \DeclareRobustCommand, \usepackage{hyperref,xcolor} and \usepackage{graphicx}

In order to tie capital letters with a capital hyphen, I created a command \DeclareRobustCommand{\capitalhyphen}{\raisebox{0.24ex}{\resizebox{0.4em}{\height}{-}}\kern-0.07em} which uses graphicx ...