{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
2answers
249 views

Redefine \emph to be both bold and italic

I'm trying to redefine the \emph command to make text bolded in addition to being italic, but when I use \newcommand{\bfemph}[1]{\textbf{\emph{#1}}} \renewcommand{\emph}[1]{\bfemph{#1}} I get an ...
4
votes
3answers
124 views

Set up class to have a variable that can be used across document

I know I can create a new command like so: \newcommand{\myname}{John Doe} \myname would then display "John Doe", However I would like to be able to do something more dynamic like the fallowing ...
9
votes
1answer
76 views

Automate correct spacing after ! in math mode

$(2n)!/\bigl(n!\,(n+1)!\bigr)$ $${52!\over13!\,13!\,26!} + 33!! - y$$ $(2n)!/\bigl(n!(n+1)!\bigr)$ $${52!\over13!13!26!} + 33!! - y$$\bye How could we automate the spacing after !? As explained in ...
2
votes
1answer
75 views

Redefine a primitive parameter

I want to redefine a primitive parameter as a macro, and make the macro behaves the same as the primitive parameter in some situations. \tracingcommands = 1 \the\tracingcommands ...
0
votes
0answers
63 views

Alias normalbaselineskip to \\ in a tabularx environment

I'm still on my way to my key:value table, and this time, I'm trying to alias [\normalbaselineskip] to \\. I still want to use the standard \\. What I want is to consider \\ as [\normalbaselineskip] ...
0
votes
0answers
49 views

Determine math font, fontsize and shape latex

How can I determine the default math font, fontsize and shape used in a document? I know I can use show for instance but I do not know which macro I need to call I want to know this because I want ...
6
votes
2answers
186 views

How to define macros in order to reuse key-value parameters?

I use the listings package to typeset code in my document. I have defined a new environment via \lstnewenvironment in which I use \lstset to set a large number of options through a list of key-values. ...
1
vote
1answer
30 views

Custom Commands for format modifiers

How would I implement this as a \newcommand \LARGE \ <Text> \Large Document class is a article. Essentially what I am aiming for is to use a command such as \formatlarge{<text>} that ...
3
votes
0answers
66 views

Convert Plain TeX automatic table generation macros to LaTex

I have written code, given at at the end of the post, to typeset exams and quizzes in plain TeX. A typical test would be typeset using: \def\CLASS{Math 111} \def\TERM{Spring 2015} \def\TITLE{Quiz 3} ...
11
votes
3answers
162 views

Use a macro to define a \NewDocumentCommand macro without backslash

Or as, Werner simplified it: "How to define a command without backslash in xparse". Background: I am trying to set up a macro to define a macro for me (which will also do some other things which ...
0
votes
2answers
69 views

Change \textheight in function of width

Good day. I want define an environment that change the text height in function of the width \documentclass[a4paper]{book} \usepackage{lipsum} \begin{document} \the\textwidth---\the\textheight ...
2
votes
0answers
75 views

soul for text highlighting, microtype for letterspacing, and xspace: incompatibility

I am trying to use soul for highlighting text and microtype for letter spacing (and other things). But I cannot get the two to work together nicely when I include xspace (I use this mainly for ...
2
votes
1answer
37 views

Manually resize a grouping macro

I know there's a braket package that will probably do all this for me but I've defined my own macro for matrix elements in Dirac notation: \makeatletter \def\me{\@ifstar\@me\@@me} ...
3
votes
3answers
124 views

Is it possible to fix the width of the included image with `includegraphics`?

I have tried to use the renewcommand do redefine includegraphics, as shown in this answer: % save the meaning of \includegraphics \LetLtxMacro\latexincludegraphics\includegraphics ...
0
votes
0answers
35 views

Custom Command Problem

I have a custom command that I got working with a lot help from this forum but I've run into a problem. When on a regular page it works fine with it adding a changebar to the margin and changing the ...
6
votes
2answers
153 views

Parse command argument separated by comma

I want to mix several language in my document, and the output language can be chosen according to corresponding variable I want to define this kind of command \mulan[en,fr,ru]{arg1}{arg2}{arg3} to ...
1
vote
1answer
35 views

Is it possible to make a command within align* environment?

I'm making some math-mode macros, but some of them try to define new commands (to use as variables) within the align* math mode. I've isolated the problem to this MWE: \documentclass{article} ...
2
votes
1answer
62 views

\pgfplotstableread dynamically create loaded table macro from \pgfplotsinvokeforeach key

I am trying to load a whole lot of CSV's using \pgfplotstableread and dynamically assign them a macro name from a \pgfplotsinvokeforeach loop. I tried \csname but suspect this is totally the wrong ...
0
votes
0answers
27 views

How to \DeclareOption with a variable? [duplicate]

I know \DeclareOption{option name}{option content} but how is this used to pass a variable number into the package? for example, \usepackage[margin=1in]{geometry} passes 1in to the margin option of ...
3
votes
1answer
64 views

Go through a list of numbers in an argument of a macro

I would like to write a macro background which takes 2 arguments and each argument can contain a list of numbers separated by ,, such that the following code draws two boxes with borders inside. ...
8
votes
3answers
539 views

What is the best way to do math inside LaTeX macros?

I'm interested in writing a little personal package (or sharing it if it's actually useful) to speed up typesetting Trigonometry. I'd like commands like ...
1
vote
0answers
55 views

Is it possible to use `renewcommand` to replace the `hyperref` command with `hyperlink`?

I am using Beamer with Hyperref, and I have a problem with the \hyperref command. The link is active, but it sends me to the first slide of the talk. I've read here in the Troubleshooting section ...
1
vote
0answers
44 views

scope of \def within a beamer document [duplicate]

The following MWE displays the problem. \documentclass{beamer} \begin{document} \begin{frame}{Frame 1} \def\test{hello} \test % prints hello \end{frame} \begin{frame}{Frame 2} \test % ...
5
votes
2answers
108 views

Using a previously defined command in a loop stops the loop

I defined a command \mycommand, and then I would like to use it in a loop like \newcounter{myc}\setcounter{myc}{0} \def\myloop#1{ \loop \ifnum \themyc <#1 \mycommand ...
6
votes
4answers
157 views

formating pgp - insert a space every four

I am an occasional latex user (means that I never used it to the point of writing a big professional text with, but wrote a few pieces for personal use) and want to create some visting cards, basic ...
2
votes
0answers
51 views

Correct way to make command defined in tikzpicture environment (in an example) available in all documents?

The wonderful answer to the question Easy curves in TikZ shares some code that is defined inside a tikzpicture environment. I share the relevant portion of the answer here: Here is a slightly ...
3
votes
2answers
134 views

LaTeX newcommand with fontname as parameter

Since I want to display several fonts I my document showing an example of the alphabet of each font I wanted to define a new command to easily get the alphabet; the code for this is the following: ...
2
votes
1answer
65 views

Beamer: problem with redefining the frames

I have some trouble with beamer: I start with a simple example: \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage{default} \begin{document} \begin{frame} first frame \end{frame} ...
2
votes
1answer
391 views

what does \z mean?

In some codes I encountered some \z command, for example: \pgfmathrandomitem\z{mylist}\z\prunelist{mylist} from this question: Generating random numbers without repetitions. What exactly does it ...
0
votes
0answers
52 views

providecommand for column vector

I'm trying to provide a command for a column vector. I defined this in the header: \providecommand{\vector}[3]{\ensuremath{\left( \begin{matrix} #1 \\ #2 \\ #3 ...
4
votes
2answers
116 views

\xdef with arguments in \newcommand?

Considering this newcommand (it works fine) \newcommand\createCMDSH[4]{% \expandafter\@ifdefinable\csname #3#2\endcsname{% \expandafter\xdef\csname #3#2\endcsname{% ...
5
votes
5answers
235 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}% ...
7
votes
1answer
69 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 ...
3
votes
1answer
262 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
46 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
6answers
319 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 ...
5
votes
1answer
116 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
72 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
3answers
117 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
97 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
106 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
70 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
161 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 ...
11
votes
3answers
131 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 ...
3
votes
1answer
60 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
93 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 ...
11
votes
6answers
543 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
25 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
93 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]{% ...
3
votes
1answer
97 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 ...