{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
4answers
72 views

Align a word to a point past the right margin

I made a simple title command: \documentclass{article} \RequirePackage{graphics} \newcommand{\modtitle}[2]{% \vspace*{-5\baselineskip}\noindent\hspace*{-.75in}% ...
0
votes
0answers
12 views

xycirc.tex problem with “;”

So I am having this problem, while using xyqcirc.tex. I called at the beginning by using \input{xyqcirc.tex}, but then before every \item, in itemize environment, or example, this symbol appears: ; , ...
5
votes
1answer
48 views

Operator with both arguments and limits

I'd like to define a command \E that can be used precisely as follows: it should translate \E{f(x)} \E_x{f(x)} into \mathbb{E}(f(x)) \mathbb{E}_x(f(x)) respectively. Specifically, the goal is to ...
164
votes
4answers
28k views

Space after LaTeX commands

I have a definition \newcommand{\arnold}{Arnold Schwarzenegger} when I refer to it by \arnold is a it is rendered as Arnold Schwarzeneggeris a In order to have a space in front of "is" I ...
10
votes
2answers
1k views

How to exclude text portions by simply setting a variable or option?

I'm writing a document where some text portions are confidential and would therefore like to create an environment (e.g. confidential) which I can then exclude from the PDF by simply setting a ...
3
votes
1answer
155 views

How can I, if possible, create a command whose output is dependent on an argument/parameter for language switching?

Question I would like the ability to work with macros in multilingual (xelatex) documents. Example Situation I have a large document in 8 languages that share a common preamble. I decide there is ...
1
vote
1answer
38 views

TeX — Non-italicized varepsilon

I'm studying TeX from The TeXbook. I was asking myself, just for exercise, if there is a way to obtain a non-italicized \varepsilon in a simple way, without using some outer package but just with some ...
9
votes
5answers
233 views

Can one avoid typing double quotes in this TikZ-involving macro?

I need to draw many similar complicated colored shapes; I made a macro for them, and it works, but to call it I seemingly have to place several color names in double quotes. Can I avoid this? The ...
3
votes
3answers
90 views

Is there a way to define a shorter command macro instead of \begin{equation} \label{}\end{equation}?

So instead of using the whole \begin{equation} {body} \label{} \end{equation} I could simply type something like \inserteq{{x+y=1}{eq1}} That would be very helpful. Thanks on advance!
5
votes
1answer
82 views

Insert something “Before the end of document”

I insert the name and licence with the command \nameofcompany at the end of my document like this: \nameofcompany \end{document} Now, I want to generalize it to some documents, for that I found ...
2
votes
1answer
70 views

How to create another styling format like \emph

I read how to change \emph and changed it to \DeclareTextFontCommand{\emph}{\bfseries}. Now I want to create another command like \secondstyleformat which I can configure aswell. Such a format could ...
2
votes
0answers
43 views

How to use variables in calculations when defining a new TikZ command

I'm trying to define a new command to use in a TikZ picture. but it seems I can't work with variables (in this case the \defs) inside the newcommand definition. At least not the way I am doing it ...
1
vote
2answers
75 views

Split single argument in multiple parts

I would like to define the command A\!\!_B\!C in a math mode as a macros, and I am using the following: \newcommand{\cmp}[3]{#1\!\!_#2\!#3} Unfortunately I get an error that there are {} missing. ...
3
votes
1answer
94 views

How should I handle a counter where the numbers do not have a pattern?

I am working on homework and problems are assigned from several sections of a book. For example, I have to solve problems 1, 7, 24 from section 1 and problems 2, 5, 9 from section 2. I do not care ...
10
votes
3answers
99 views

How to defer content to a later part of the document?

I want to create a collection of problems, each problem consisting of the problem itself, optional hints and optional solutions. I wanted to know what would be the best way to do it ? I could use ...
5
votes
2answers
75 views

How to get \ifcase to work with a macro argument

How can I make the \ifcase statement accept my \myindex macro as an argument in the following example. On its own, the \myindex macro expands correctly, however, I get an error when I use it as the ...
3
votes
1answer
45 views

Calling the GDI Popup Interface with Own Macro to Pull Gathered Lables

In this Previous Question I was able to gather labels with a Macro I created. Now I've got the opposite problem. I want to pull to pull up that nice GDI Popup Interface when I use a macro. Here's ...
2
votes
1answer
38 views

Duplicate and modify section hierarchy

In a large thesis style document being prepared, there are certain parts (latex hierarchy \part{}) that are being treated as insertions of previously prepared work. This may include articles or ...
2
votes
2answers
138 views

Custom Macro for Sum Symbol

I want to write a macro which makes a transformation for the sum symbol. When i write: \csum_{i = 1000000}^{n} it should be converted to this: \sum_{\mathclap{i = 1000000}}^{n} \; How can i do ...
2
votes
1answer
26 views

How to change theorem numbering when macro file is involved

In my macro file, I have certain theorem environments defined, for example. \newtheorem{theorem}{Theorem} \newtheorem{lemma}[theorem]{Lemma} \newtheorem{corollary}[theorem]{Corollary} ...
34
votes
3answers
2k views

Nicely force 66 characters per line

I would like to have "something" (a package, a trick, a macro, ...?) that makes it possible for me to nicely play with the margins (or the layout) in order to set the average or typical number of ...
10
votes
6answers
460 views

How to do centered interlinear text in LaTeX

How to do interlinear text like below? Especially, number over the word is centered in relation to this word. I tried with hbox and centering command but not works. ...
2
votes
2answers
71 views

define a macro with two parameters delimited by optional spaces

I want to define a macro with two parameters which delimited by optional spaces. For example, from the following code \def\mymacro #1 #2 {#1:#2 } \mymacro one two others I get one:two others. But ...
4
votes
3answers
78 views

How to define such a command with an optional argument in my class?

I'm preparing a document class: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{myclass} \LoadClass{book} \RequirePackage[demo]{graphicx} \newcommand{\@mypic}[1]{% ...
0
votes
0answers
24 views

\newcommand{\name}{Name} to change a keyword in different versions [duplicate]

Well, I'm using \newcommand{\Name}{Name } so I can change the name for different versions of my pdf. When I use it like {Name }, with a space bar, sometimes in the text it gives 2 spaces, and ...
10
votes
2answers
337 views

Trimming whitespace around text (like LTRIM, RTRIM and TRIM)

When working in Excel with text strings, it is convenient to use the LTRIM, RTRIM and TRIM functions which removes white space around text string. What would be an efficient way of duplicating this in ...
3
votes
1answer
74 views

Automatically clean (numerous) customization macros gathered in an auxiliary file

I have to gather, in a single source file, source files from several authors, each of them with its own (many) \newcommand, \newtheorem, etc. I'd like to limit the scope of each of these ...
2
votes
1answer
59 views

Suggestions for nested proofs

I would like to write down my lecture notes. The proofs of the theorems in this lecture are usually really big. It usually looks like this: Theorem 1: Here comes the statement of the Theorem ...
4
votes
1answer
34 views

Create commands for displaying pictures from a list of files

I have a lot of pictures to show in my document. My idea is to create one command per picture. So I try to use foreach command (maybe not the best for this...). I store the filenames and the names I ...
3
votes
1answer
46 views

Nested or variable functions of xstring

My idea is to use xstring package for dealing with some string tests. In my case, I used the \strLeft function for extracting the 3 first letters of a string. Then, I use this result in \IfStrEqCase ...
6
votes
0answers
56 views

What are the uses of \@bsphack & \@esphack

I see the macro duo: \@bsphack ... code ... \@esphack appearing in different places. I noted that it suppresses spaces around the macro in which these commands are used, but when do you need to ...
5
votes
2answers
72 views

A key-value side effect

In one of my macros, I wanted to set some width to either two-column or single column width. In other macros I do use key width, so I wanted to store the requested width in that key. So my first ...
4
votes
1answer
40 views

array and command in column' s definition of table

to develop a specific class, I would like to define columns in a table by a macro definition. Like in this MWE \def\titi{c|c|c} \begin{tabular}{\titi} a& b&c\\ a& b&c\\ a& ...
8
votes
2answers
111 views

Is it possible to pop a command from the \@preamblecmds list?

Is it possible to pop a command from the \@preamblecmds list? The use case I have in mind is to allow \DeclareMathOperator to be used after the preamble.
2
votes
1answer
37 views

environment within environment within command

So.... I'm trying to create (what I assume) is to be a simple command that tries to do some nice formatting. Here is what I have. \usepackage{enumitem} \newenvironment{question}{\bf}{\normalfont} ...
4
votes
1answer
157 views

LaTeX: macro templates

Often at the end of astronomical papers there is written that it was created using the AAS LaTeX macro v5.2 . Do I understand this right that one can download such a template with all preamples at the ...
4
votes
1answer
56 views

Detecting currently running executable - and usage of Latex?

Somewhat in the similar vein as Getting Texlive version in pdflatex?, now I want to obtain the currently running executable inside a *tex run. Thanks to Write18: capturing shell (script) output as ...
2
votes
0answers
118 views

What is the meaning of \+ in doxygen-generated latex? [closed]

When compiling a software reference manual with doxygen and latex output, I get the following error: ! Undefined control sequence. l.2 ... Modular System for Shelves and Coasts (M\+ ...
3
votes
2answers
49 views

Tex macro needed to display mercurial keywords

I have mercurial keywords in a latex doc which I wish to process. \documentclass[12pt]{article} % This macro is an example based on the UK Tex FAQ: % ...
6
votes
2answers
197 views

Problem with catcode of @ (at-sign) in a package

I have put the following in example.tex: \catcode`\@=13 \let@\IND The problem is when I want to use my package eexxample.sty that contains example.tex, the comand @ won't come out, it will turn ...
4
votes
2answers
40 views

Empty groups {} when writing environment contents verbatim (but with expanded macros)

In answering this question, I noticed some trickiness regarding empty groups {} in an otherwise verbatim context. Suppose you capture the contents of an environment verbatim (as in that question), ...
4
votes
1answer
320 views

adding online profile pages to moderncv

I have been using moderncv and I was thinking of adding my stackoverflow and github profiles to my resume, unfortunately there doesn't seem any macros for that (is there?) I wasn't using ...
4
votes
2answers
122 views

How to keep text together

I am currently creating various macros in order to format text. Now I want to keep certain information together. It seems that there are two ways in order to achieve this: Use boxes such as mbox Use ...
6
votes
2answers
113 views

TeX/LaTeX: Macro for getting a length as number

I would like to write a macro getlengthin to get a length or dimen as floating point number in a specified unit. Here is what I have created so far: \documentclass{article} ...
5
votes
2answers
84 views

macro with \newcommand using foreach to create tree in tikZ

In the two examples below I use the same code in two different ways. Why is it that TikZ gets confused about who the parent node is when using the macro \department{name dept}{list of subdepts} ...
5
votes
2answers
50 views

Help with a \newcommand not working with autonum

I am writing my thesis. To write math formulas I created the command \eq as follows. \newcommand{\eq}[1]{ \begin{equation} \begin{split} #1 \end{split} \end{equation}} However, now I want ...
6
votes
2answers
329 views

Draw rectangle with two foci (like an ellipse)

How can the code be improved? Can I make the variables local? \documentclass[12pt,tikz,border=5pt]{standalone} \usetikzlibrary{calc} % this is from % ...
2
votes
0answers
32 views

Automatically return list of all uses of a command, without repeats e.g. \compound using chemstyle

I'd like to automatically generate a comma separated list of all occurrences in my .tex file of a particular command. Specifically, I want to ensure the correct numbering of chemical structures using ...
6
votes
4answers
157 views

\newcommand with optional argument

The idea is define a command as \newcommand{\mycommand}{This is the official long name} and I use it as \mycommand several times in the document. But sometimes I would like a short name, something ...
9
votes
2answers
108 views

How to define a command that produces a different savebox depending on the argument

I'd like to define a sequence of saveboxes \fooA, \fooB, etcetera, in a style file and introduce a command like \newcommand{\foo}[1]{....} which produces \usebox{\fooA} if the argument of \foo is 1, ...