{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)

0
votes
2answers
39 views

Parenthetical clauses with a mechanism similar to csquotes' MakeAutoQuote

I have the following macro for writing parenthetical clauses: \makeatletter \newcommand\incise[1]{% ---\,#1% ...
3
votes
1answer
49 views

Using \newcommand with ellipse in tikz

I want to use some constants, height and width, when creating an ellipse but it won't work with \newcommand. Here is a minimal example: \documentclass[12pt, a4paper]{article} \usepackage{amsthm, ...
4
votes
3answers
152 views

NewDocumentCommand with argument specifiers stored in macro

I am trying to write some macros that in turn automatically generate other macros, depending on options etc. I wonder, if it's possible to use \NewDocumentCommand{\somename}{\standardargs}, i.e. the ...
3
votes
1answer
64 views

rewrite comand like a [key=value] using xparse or latex3 syntax

I've written a macro to use some command like a ltxdoc (\oarg,\meta,\marg) without using the textcomp and ltxdocto colorate and decide the font style with which the angle, brackets and text in ...
2
votes
1answer
53 views

Detect whether there's space before and after macro

My document has a custom macro called \newcommand{\myparenthetical}[1]{[#1]} However, I want to be sure that in the document I always have a single space before and after the macro. I would like ...
3
votes
2answers
120 views

Passing complicated argument patterns to a new command

I am using the nice changes package. Which basically provides three commands \added, \deleted and \replaced. Because of the structure and the fact that the optional arguments it takes, I think it is ...
11
votes
3answers
270 views

Treating the contents of a TeX-style group ({\blah …}) as macro arguments

I am trying to make adjustments to a large document that uses TeX-style macros, like this: {\defun SomeFunctionName arg1 arg2} The \defun macro is defined as \newcommand{\defun}{\tt}. Can I ...
14
votes
2answers
261 views

How to define a wrapper to a command that takes an optional argument?

What is the proper way to define a wrapper to a command which takes an optional argument (such as \chapter)? I mean a wrapper, not a clone, such that we can inject code into the wrapper without ...
1
vote
1answer
34 views

How to pass text/strings from main file to beamertheme via beameroptions or is there an alternative way?

In this and this question I learned how to pass simple definitions like a location from my main file to a e.g. beameroutertheme. However this approach fails for longer strings or text blocks, in this ...
2
votes
0answers
27 views

\ifbeamer@anotherslide and \ifbeamer@localanotherslide in beamerbasedecode.sty

At the beginning of the source file beamerbasedecode.sty of beamer class, two switches are defined: \newif\ifbeamer@anotherslide \newif\ifbeamer@localanotherslide By reading beamerbasedecode.sty ...
5
votes
1answer
56 views

Unused \setbox0 in beamerbasedecode.sty

Inside the source file beamerbasedecode.sty of beamer package, there are the following lines: \def\beamer@stoptexts{| stop:0| } { \catcode`\|=13 \catcode`\:=13 \catcode`\,=13 ...
1
vote
0answers
34 views

How to include input filename in error message?

I want to add an error message to a class I'm building for when the user (which will generally be me...) forgets or messes up a macro call sequence. I can do this: ...
2
votes
1answer
51 views

Disable some xunicode macros in case of T1 font encoding?

I was hoping that, except for inputenc/fontenc versus fontspec, old .tex files encoded in UTF-8 could be used without changing anything with either pdftex, xetex or luatex engines. But the following ...
0
votes
0answers
46 views

script to create a table with multiple rows

I'm wondering how to quickly put a bunch of data into a table. I have a rather basic knowledge so I'm asking for a way to read in data by the following format: It has 4 columns, first is formatted in ...
2
votes
2answers
127 views

Why is this macro putting an element of a table on the wrong row?

Consider the following MWE: \documentclass[a4paper,10pt]{article} \newcommand{\macro}[2][]{% & something & #2 & #1 \\ } \begin{document} \begin{tabular}{lccc} \macro{3}{4} ...
7
votes
3answers
120 views

Use the result of FPeval to color a table cell

I am trying to give a table cell a grayscale color value based on it's numeric value. So far I have the following code \documentclass{article} \usepackage{fp,xcolor,colortbl} \FPeval{\resb}{0.5} ...
6
votes
2answers
165 views

How to typeset the percent symbol inside \detokenize?

I am writing some personal notes about R programming. I defined a macro to typeset R functions and operators using a different font style and color: \newcommand{\rtext}[1]{% ...
8
votes
2answers
322 views

Is this sacrificial command a good idea?

I have this command: \newcommand{\name}[1]{\edef\name{#1}} You first call it as in \name{Don} and afterwards you can refer to Don using \name. Is this an accetable way to express a constant that ...
0
votes
1answer
83 views

\newcomand causes failure [duplicate]

im new to Latex, so pleas make explenation easy ;) im working with latest latex version on miktex i tried some \newcommand today and caused an error with this command: \newcommand{\N0}{ n_{0} }. when ...
2
votes
2answers
50 views

Keeping underscores in parameters even inside NewEnviron environments

I followed this answer to define a command such that underscores in its parameter can be kept. However, this does not work if the command is called inside an environment that has been defined with ...
4
votes
1answer
49 views

Setting a counter to a value obtained by expansion

I use the glossaries and minitoc packages. Minitocs are generated for all glossaries printed in the table of content, eg with the toc option for the glossaries package. When one prints the glossaries ...
4
votes
1answer
140 views

How to use a command as path in 'includegraphics'?

I want to include a graphic by using \includegraphics{\mycommand} but it doesn't work. The path to the picture will be a combination of text written in .txt files. This is my code: ...
5
votes
2answers
128 views

How can I automatically replace all accentuated characters by the corresponding codes in TeXnicCenter?

First I want to apologise in case the question has already been asked, although I failed to find the topic on this site. So here's the thing : I've recently begun to type my lessons in LaTex using ...
1
vote
1answer
41 views

How to define commands for additonal information in beamer main file for use in themes?

In a typical beamer document I can set various options like \author or \title: main.tex \documentclass{beamer} \author{George Orwell} \title{Animal Farm} \date{\today} \institute[TUD] ...
3
votes
1answer
71 views

tikz/pgf upgrade and decorations

Since a major upgrade in pgf, my code does not compile any more. I am trying to make "decorated" source listing, where the decorations can be like highlighting some lines (see the MWE), balls on some ...
3
votes
1answer
28 views

Redefine command inside page header

I’d like to redefine a command inside a page header that’s generated using scrheading. The reason for this is that the page header should be in all-low-caps; however the chapter header happens to ...
4
votes
1answer
98 views

\begin{document} breaks redefinition of \Re

To replace the Gothic type real-part operator by a plain 'Re', the following works for me: \documentclass[a4paper,11pt,twoside,fleqn]{report} [...] \usepackage{amsmath} \usepackage{mathtools} ...
3
votes
1answer
67 views

defining a new infix command

This question kind of already exists here: How to write infix macro/newcommand? But I'm not looking for a way to divide using an infix command, which I know there already exists a command for. I'm ...
4
votes
1answer
54 views

Passing escaped special characters for use as a URL through macros

From an earlier question on Escaping special characters for use as a URL, using \string to escape the special URL characters in the second example works great: \DefineMyFormatLinkParameters{% ...
4
votes
1answer
106 views

Escaping special characters for use as a URL

If a url contain special characters (~ and #) using it as \href{http://people.brunel.ac.uk/~mastmmg/ssguide/set_work.html#4_32}{people.brunel.ac.uk} works just fine. But, I would like to have macro ...
5
votes
3answers
101 views

Issue: string manipulation with links inside

I have defined a new command \openintro which I call at every chapter of my work. This command basically constructs a lettrine sentence, like the image below (don't bother with text style): ...
2
votes
2answers
108 views

Patching local commands defined within other macros

This is the follow-up - question, respectively the main cause which led to the (yet) unanswered question here: \xpatchcmd defines macros when applied to undefined commands I tried to patch some ...
7
votes
2answers
467 views

How can I write a macro which enters math mode when called in text mode but when called in mathmode doesn't break?

I'm using the package braket for my physics notes, and this speeds things up a great deal but I'm constantly writing \ket{\psi} or \bra{\psi}, and because this specific pair of bra and ket appears so ...
12
votes
1answer
176 views

\DeclareTextSymbol and \DeclareTextCommandDefault in contrast to standard \newcommand et al

In this answer egreg used the macros \DeclareTextSymbol, \DeclareTextCommandDefault and \UndeclareTextCommand where I had previously (and unsuccessfully) tried a simple \newcommand or \let. Could ...
2
votes
0answers
23 views

Vertical spacing in `\newcommand`s [duplicate]

Consider the piece of code. \documentclass{article} \newcommand{\hello}{Hello world!\vspace{12pt}Hello again!} \begin{document} \hello \end{document} This produces the following output. ...
0
votes
0answers
21 views

Macro spacing mystery [duplicate]

I get different spacing results when I define a \hspace directly or as a macro. Directly: \documentclass{article} \title{Title} \author{Daniel Domingues \hspace{0.2cm}$\diamond$\hspace{0.2cm} ...
2
votes
0answers
27 views

How to pass an argument as a new command's name? [duplicate]

\documentclass{article} \newcommand*{\DefineRealCommand}[1] { {The real command name is: #1} \newcommand*{\#1}{I am the real command.} } \DefineRealCommand{HelloCommand} \begin{document} ...
10
votes
1answer
113 views

\xpatchcmd defines macros when applied to undefined commands

I stumbled over this feature (it's part of a bigger question, but I splitted it into two questions): Say, that we want to use \xpatchcmd (from xpatch) or \patchcmd (from etoolbox) and apply those ...
4
votes
2answers
606 views

LaTeX “Variables” - \@varname

I'm currently in the process of writing my first document class file (a personalized resume class), and I want to get a better understanding of what exactly I'm doing. So, right now I'm setting up ...
4
votes
1answer
42 views

mhchem macro in subscript

Consider the following MWE \documentclass{article} \usepackage[version=3]{mhchem} \begin{document} \begin{equation*} % c_\ce{CO2} not working c_{\ce{CO2}} \quad c_\text{working} \end{equation*} ...
4
votes
2answers
184 views

Need a Macro for Tables - independent of row and column size

I have created the following macro for Table: \newcommand{\createtable}[7]{ \begin{table}[htbp] \begin{tabular}{|p{8cm}||p{8cm}|} \hline \begin{center}\textbf{\cellcolor{Orchid!25}{#1}}\end{center} ...
1
vote
0answers
110 views

Failure After Using Latexdiff Script: latexdiff marking up lstlisting environment

After running a script to use latexdiff on a multiple input latex file I am left with a diff.tex file that is generating the following error: ./diff.tex:7009: LaTeX Error: \begin{description} on ...
5
votes
1answer
58 views

Nested \newcommand for creating maps

I want to create a simple map using \newcommand. My \NewMapItem command defines another command which returns item's value. \MapItem simply replaces to that command. \documentclass{article} ...
7
votes
2answers
106 views

New Command For Inline Code

I am using the listings package to enter large blocks of code into my document, however I am trying to write a custom command that uses my current settings to do inline code. For example I want to be ...
2
votes
1answer
37 views

Text in custom command overflows the page

This text is connected to solution described in this question: How to user bold in custom command? When I use this custom command: \newcommand*{\myfont}{\fontfamily{pcr}\bfseries} ...
4
votes
2answers
147 views

Unicode macros for square root and integral

Is it possible to define math-mode macros √ and ∫ which would expand in the following way: √a ≡ \sqrt{a} √{a + b} ≡ \sqrt{a + b} ∫ ≡ \int ∫_a ≡ \int\limits_a ∫^a ≡ \int\limits^a ∫_a^b ...
7
votes
1answer
87 views

TexStudio: Enable spellchecking in user-defined commands

I am trying to find a way to enable spell-check in cases such as: \remark[I don't understend this]{$2+5=7$} I found something that might look as an answer but it sadly does not work ... In ...
1
vote
2answers
79 views

Getting an error when defining a macro in a TiKZ picture

I like a certain style of vertices in my TikZ drawings so I want to define a macro to save time formatting. It has two arguments, one names the node, the next is its location. It should have a blank ...
1
vote
1answer
106 views

Command already defined (custom command)

When compiling following code, I the compiler tells me that a command is already defined (the name is \c@b...). \documentclass{article} \usepackage{calc} \usepackage{ifthen} \usepackage{tikz} ...
5
votes
2answers
128 views

Use \foreach loop to execute macro with parameters of macro provided in a list

I have to execute a macro a number of times, and would like to provide a list of the parameters to be executed. So, instead of \FormatLinks*[Main Search Site]{Google}{http://www.google.com} ...