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

how to return protected command with one argument already validated in latex/tex?

I want a command that will create an unevaluated bit of LaTeX/TeX code (to be evaluated at the end of an environment, but this is not necessary information) that has been created using an evaluated ...
13
votes
2answers
243 views

Persuading (la)tex “silently to go beyond the envelope of 'good taste' ” to avoid an overfull hbox

My understanding, based on reading this website, is that (la)tex performs at most three passes when trying to typeset a paragraph: one based on \pretolerance, one based on \tolerance, and one based on ...
3
votes
2answers
397 views

Change existing symbol size

I would like to make the \circ symbol smaller and centered when using it between two letters. For example, I want to say \begin{align} \forall\ a,b,c \in S,\ a\circ( b\circ c)= (a\circ b)\circ c ...
1
vote
1answer
92 views

How to output the choices of the questions inside a box?

I plan to create a command where I can use to output the choices inside the box and above the list of questions but its a know how. This is a sample output of what i am saying. I will use the ...
3
votes
1answer
176 views

Aligning three small box together with a text

I made through creating the boxes inside a box with help of an expert by this link Is three boxes inside a box posibble in latex Now im being troubled on how will i put into command to align this ...
4
votes
1answer
232 views

New command based on command name

I had this idea that would save me a considerable amount of time in writing my thesis. Here's the deal: I need to typeset lots of equations with vectors and matrices in them. I'd like my vectors in ...
3
votes
1answer
451 views

Automatic break line after multicolumn

Is there a way to put \\ after multicolumn automatically, each time it appears in the code? Pseudocode would look like this: \newcommand{\commandThatAddsBreaklines} if(thereIsAMulticolumn == true) ...
2
votes
1answer
291 views

Redefine existing command

My question is whether I can redefine an existing command for example \multicolumn and make the required arguments optional, without loosing the content of multicolumn? Another option would be to get ...
2
votes
0answers
122 views

The meaning of the percent sign in LaTeX coding [duplicate]

Possible Duplicate: What is the use of percent signs (%) at the end of lines? I know that % is commonly used to uncomment parts of the code, but recently I read that there is another use ...
0
votes
1answer
79 views

Creating custom tabularx

I am trying to create a new environment in order to change the layout for tabularx, since the original is not looking like it should. I want the picture to be on the right side wrapped by the text. My ...
7
votes
1answer
272 views

How do I reuse a command name?

I like to give my commands names that correspond to their meaning rather than symbols they produce. For example, I would like to use the symbol \amalg to denote binary coproducts and \coprod to denote ...
7
votes
2answers
3k views

Commands argmin and argmax in algorithm

I am trying to use the argmin and the argmax commands that I defined in an algorithm but I keep getting the argument not in the middle but on the right. Does anyone have an idea how to put the ...
8
votes
5answers
371 views

Define a command (possibly recursively) to wrap text in a command n times

I'm trying to define a new command \multiboxed in LaTeX so that I can put n boxes around an equation without having to manually nest \boxed commands. So far I have (using the pgffor package): ...
5
votes
2answers
399 views

Recursively defined macros in TeX

After receiving a nice answer to a previous question, I got enthousiastic and tried to create a macro \sum such that \sum<1+2+3> would be expanded into 6. My idea was to work recursively, using ...
7
votes
1answer
235 views

Using structural commands in \newcommand - structure messed up?

Is it right that usage of structural commands like \chapter, \section, \subsection and the like inside of \newcommand screws up the document's structure? I've got a \section*{...} inside a \newcommand ...
6
votes
3answers
118 views

How do I handle a closing brace in a 'character scanning' macro?

Problem I need to define a command that grabs all numerical digits following it and leaves the rest alone. Eventually I came up with this: First Solution \RequirePackage{xstring} % for \IfInteger ...
12
votes
2answers
279 views

A macro to typeset a difficult table

The following table was created with the following LaTeX-code (mwe): \documentclass{article} \usepackage{tabu} \usepackage{multirow} \begin{document} \newtabulinestyle{stip=on 1.5pt off 2pt} ...
6
votes
1answer
542 views

new command for the dx of intergral. [duplicate]

Possible Duplicate: What’s the proper way to typeset a differential operator? \newcommand{d}[1]{\:\textrm{d}{#1}} That is my new comamnd for writing the dx of an intergral. Just wanted ...
5
votes
1answer
268 views

Getting incorrect underscores from macro in an lstlisting

I have a macro that I define as \newcommand{\versionPath}{5\textunderscore0\textunderscore7} to denote the word *5_0_7*, which I use in lstlisting's like this: \begin{lstlisting} ...
5
votes
1answer
252 views

Problem with xargs package

I am trying to do what I though was fairly simple - use an xargs defined macro in a CS. MWE: \documentclass{article} \usepackage{xargs} \usepackage{etoolbox} \makeatletter \def\abx@foo@baz@bar{test} ...
3
votes
1answer
1k views

Undefined control sequence on legitimate LyX macro

I'm trying to define a LyX macro, Insert -> Math -> Macro on the menus. It's a very simple macro. Source code under View -> View Source: \global\long\def\Z{\mathbb{Z}} The file compiles nicely if I ...
8
votes
2answers
211 views

Eating a dot after a command

I have a bibliography in which URLs are printed with a following "." I would like to omit the URLs to save space and I could do this by redefining the URL command, but this would leave me with a dot. ...
1
vote
0answers
33 views

Why is there no space after my new command? [duplicate]

Possible Duplicate: Space after LaTeX commands I defined a new command: \newcommand{\quickSubstitution}{$x \in X$} However, then I use the command as such \quickSubstitution must hence ...
0
votes
1answer
455 views

Create a static box in LaTeX

How can I make a command to automate the creation of a box? This box would enclose texts or statements, questions and the like when the command is used. Example:
0
votes
1answer
265 views

\huge and \newcommand variable don't work together

I want do define a project name somewhere and use it all through my document – but I get problems when trying to use my project name in the document title which should be quite big, so I tried this ...
13
votes
2answers
583 views

Why are these commands considered as bad practice?

I was reading LaTeX: Do not use these commands, but the author didn't explain why they are bad. Could anyone help me understand. \\ (except inside a special environment like tabular, array, or ...
10
votes
1answer
101 views

Creating Command with environments

So I repeatedly use this format for embedding a picture and some text beside it, \begin{tabular}{l l} \begin{minipage}{0.3\textwidth} \includegraphics[SCALE]{NAME} \end{minipage} & ...
4
votes
3answers
201 views

Shorthand for variables lead to name clash

In formulas I need often the same constants and variables with lot of "make-up". I want to have readable and maintainable LaTeX code, so I thought about writing \newcommands like ...
7
votes
3answers
581 views

parse variable length comma separated list into command

I've been trying to modify the solution here into a LaTeX3 command that takes a variable length comma separated list of numbers and an optional argument (a unit) and prints the square root of the sum ...
25
votes
2answers
598 views

Programming TeX macros so that they output instructions to rerun the compilation

This question is motivated by the behavior of the tikzmark macro created by Andrew Stacey, and a recent discussion with David Carlisle on chat. I have noticed that LaTeX code using tikzmark typically ...
10
votes
3answers
321 views

Ignore commands when compiling

I have defined some custom commands that I use for TODO-notes. If I write a note i use the command \stefan{}. Now I want to define a new command, for example \supervisor{}. I need a way to get ...
2
votes
1answer
174 views

Generate list of undefined control sequences/used newcommands

I have a long tex file which uses many newcommands/providecommands sourced in from a separate file using \input{}. To upload to a preprint server I would like to keep only those commands which are ...
2
votes
1answer
243 views

TikZ: variable in calc syntax

I'd like to draw some lines where one of points should be defined like: ($ (A)! \X3 !(B) $) where \X3 is something from (0,1). But it's not working. Yeah, I could just place the right number, but ...
4
votes
1answer
86 views

starred version of DeclareRobustCommand

I generally use \newcommand* instead \newcommand whenever it makes sense, to ease error checking if the command doesn't sensibly take multi-paragraph arguments. Is there a starred version of ...
17
votes
1answer
387 views

How do I make a macro require math mode?

I have defined a macro that I would like to be used exclusively in math mode. In order to enforce this, I would like the macro to throw an error message whenever it is used outside of math mode. What ...
7
votes
1answer
158 views

Automatically convert \left to \Bigl

I have a LaTeX file, which includes tons of other auto-generated LaTeX files containing TikZ figures. Suppose I want to make every \left( in the TikZ figure appear at the same, fixed size, say \Bigl(. ...
9
votes
3answers
287 views

Create macro with several options

I struggle to create a macro that can take several options. What I want to create is for \mycommand[up,middle]{Macro} to output Macro with 'up' and 'middle' specified. Using etoolbox in the MWE below ...
2
votes
1answer
91 views

How to create a column layout from a number of choices?

I am trying to create a command namely \twoc to make a simple two column answer space for a specific question. The output should appear like this: While my code for the .tex file that I will be ...
2
votes
1answer
227 views

Define a macro for inserting a \begin \end listings block

Can you define a macro that would take a listings code as a parameter and insert it inside a \begin{lstlistings} \end{lstlistings} block? My idea is something like this: ...
8
votes
3answers
281 views

Indirectly defining two active characters within an \AtBeginDocument command

I'm trying to define a macro that uses two active characters inside an \AtBeginDocument command. I can write a macro such as the following using only one active character: \catcode`\_=13 \begingroup ...
7
votes
2answers
377 views

How is the LaTeX 2e made?

I wanted to know how is the \LaTeXe symbol () made, I mean, the command definition of superscripts and subscripts on the "L", "A"... letters.
7
votes
3answers
456 views

Function to define how many lines to be displayed

I have just made a command in my own document class wherein if I type: \mline it would automatically output 5 lines only. My problem would be producing lines by just defining how many lines I want to ...
4
votes
2answers
285 views

Different macro behavior when supplied an argument

I want to define a macro, call it \func, so that \func will output\phi, and \func[i] will output \phi(i). what is the easiest way to achieve this? I know there are other questions that address this ...
1
vote
1answer
140 views

Creating and using commands/counters which name depends on other counter

I would like to know how can I use a counter for defining other new counters. Something like this: \newcounter{foo} \stepcounter{foo} %% Perhaps more increments, this depends of the user. %% And ...
5
votes
1answer
244 views

Argument names for autocompletion in Kile

Let say I created the following command in my latex document \newcommand{\red}[1]{ \textcolor{red}{#1} } When working with the LaTeX editor Kile, the autocompletion gives me something like ...
12
votes
1answer
137 views

Custom “counter” as page number substitute

I'm trying to typeset a book, covering a world trip. Instead of standard page numbers, I want each page to correspond with a digit representing driven kilometers. Of course I can't manually set that ...
7
votes
1answer
121 views

Defining a macro whose syntax includes another macro's syntax

I've defined the following macro: \begingroup \lccode`\~=`\#% \lowercase{\endgroup% \def~ #1\par}{% \begingroup\def\par{\endgroup\par}% \section*{#1}\par}% \catcode`\#=13 But if I go on to define a ...
5
votes
1answer
97 views

Handle currencies correctly depending on language conventions

Is there a standard way of handling currencies? Example: in American, you'd say "$2 a piece" in French, you'd say "2$ pièce" I'd like to be able to write \somecommand{dollars}{2}, that would ...
8
votes
2answers
201 views

What is wrong with this TeX macro

Still soldiering on with trying to learn these macros. Can someone tell me why this isn't working? The macro \mycline{n-n} is supposed to expand to \cmidrule{1-1} ... \cmidrule{n-n}, but in my code ...
2
votes
0answers
89 views

Is there a \text… command for Cyrillic characters? [duplicate]

I am trying to get the Cyrillic variant of the Serbian alphabet and was wondering if there was an easy \text command for Cyrillic characters? For example, I can easily get the letter З by typing ...