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

5
votes
1answer
79 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
0answers
37 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 ...
3
votes
2answers
78 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!
3
votes
1answer
93 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 ...
5
votes
2answers
71 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
43 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
2answers
134 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 ...
10
votes
3answers
97 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 ...
2
votes
1answer
25 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} ...
2
votes
2answers
67 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 ...
10
votes
6answers
452 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. ...
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 ...
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]{% ...
2
votes
1answer
56 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
33 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
45 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 ...
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
37 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
109 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} ...
6
votes
0answers
55 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 ...
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: % ...
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 ...
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
39 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
2answers
120 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
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
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, ...
3
votes
1answer
35 views

Bold paragraph symbol in redefined paragraph command

I have redefined the paragraph command, so that a paragraph symbol is pronted along with the number. \renewcommand{\theparagraph}{\S \arabic{paragraph}} ...
2
votes
2answers
108 views

New command, load multiple images

I have to load multiple images to my thesis. Its about 320 pictures to shortcut this, I want to make a new command to load them more flexible. My basic idea was to create a new command with multiple ...
6
votes
2answers
326 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 % ...
3
votes
1answer
33 views

(e)def and BibLaTeX

I'm trying to understand why the following code does not work: \documentclass[12pt]{book} \usepackage{polyglossia} \setdefaultlanguage{french} \setotherlanguage{english} ...
0
votes
2answers
104 views

How to create labels and references automatically in LaTeX?

I have defined two custom macros: \translation{ORIGINAL}{TRANSLATION} \printtranslations The first macro prints out the translation and puts the original and the translation into a list. The list ...
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 ...
4
votes
2answers
87 views

Enhanced fill-in-the-blank document

I am about to improve my lecture slides from last semester. Specifically, I would like to add a fill-in-the-blank option. I found this code suggestion (from here): \documentclass{article} ...
8
votes
3answers
211 views

Preferred way to define a text command (with or without a parameter)

Which of the following declarations is preferred when defining new textual macro's in latex \newcommand*{\dosomething}[1]{\textbf{#1}} versus \newcommand*{\dosomething}{\textbf} textbf is just ...
4
votes
2answers
95 views

Explanation of the usage of a particular new command to personalize it

A guy had a problem personalizing his ToC, and you helped him suggesting to use this lines: \newcommand{\mychapter}[2]{ \setcounter{chapter}{#1} \setcounter{section}{0} \chapter*{#2} ...
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} ...
3
votes
1answer
36 views

Custom .sty warning on specific command

I am writing a custom .sty file and I notice that it can break if a certain command, native in Latex, is called. I would like to throw a warning to the user and say "Don't use this command!". I know ...
5
votes
1answer
140 views

Macro in Tex Programming

I am confused whether the below macro is for section or what? If yes can anybody help me to explain this piece of code \def\Section #1 \par { \bigbreak\vskip\parskip \need 1.5 in ...
0
votes
1answer
58 views

Reset a renewcommand

I have found a Resumé template in Latex. I would like to change the following part of the template but my knowledge of Latex is not that extended. % Every \item can be followed by one or more ...
6
votes
6answers
241 views

command for printing only what has been specified as A or B

Suppose I have a document like the following: % !TEX TS-program = lualatex \documentclass{scrartcl} \newcommand{MyCommandForPrintingOnly}{...} \newcommand{MyCommandForSpecifying}{...} ...
0
votes
0answers
21 views

How to change the \namedata of examdesign?

I know a little about TeX or LaTeX. I am just making an math exam for my students and I am using examdesign because it randomizes the questions. But, my problem is that these students are High ...
4
votes
2answers
72 views

Some text or symbol after \item element

I want add some text after of each element \item. For example, I defined a new command \newcommand{\qitem}{\item?} %For the list of questions \begin{enumerate} \qitem Some question \end{enumerate} ...
3
votes
1answer
34 views

savelowerto option from tcolorbox fails inside a wrapper command

I am experimenting a little bit with a favorite package of mine: tcolorbox, the following code is cut out/reduced from a larger 'project', cut down to a command \newcommand{\splitmycontent}[2]{% ...
6
votes
2answers
167 views

How to make latex parse `x` as an argument of a macro definition instead of `#1`

When I define a mathematical function for plotting in pgfplots or pstricks I usually to it in the following way: \def\f(#1){(#1)^3 + 3*exp(#1)} just as suggested by Jake in his answer to a ...
3
votes
2answers
97 views

width of \parbox issue

I am using a template for a CV in LaTeX and I am facing certian difficulties in getting things aligned properly. The code I am referring to is \newcommand{\NewEntry}[3]{% Define a command for each ...
7
votes
3answers
197 views

Expanding macros within \csname

I have some macros that expand to some text but when used together they should expand to something completely different. In this example: \foo -> x \bar -> y \foo\bar -> Hello World Doing it with ...