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

1
vote
2answers
75 views

Define a section-like command with three parameters

I'm looking to define a section-like command for a CV document that takes three arguments: role, company, and time - like shown below. Because I lack the TeX experience I used the titlesec package but ...
3
votes
2answers
66 views

Show variable name, measurement unit and value in a single command invocation

I am using the fp package to write a coursework in mechanics and calculate the numerical values on the fly. Here is some example code: \documentclass{article} \usepackage[nomessages]{fp} % ...
2
votes
0answers
37 views

Adding default \skew to math accents

Out of corporate design reasons I should use Helvetica for my documents. I could simply ignore this, as most people do ;-) But out of fun I just combined ideas taken from sfmath and beamer to make ...
3
votes
1answer
83 views

Adding a parameter to a new tikz command

I want to add a parameter to a tikz command. I now have 5 ray's on a mirror, but I want to make it possible to add an angle and a point on the mirror where to ray reflects on the mirror. So is it ...
1
vote
1answer
39 views

pgfplots: help with macro to drop line to x-axis

I frequently produce plots where I need to label points on a function, which I prefer to do both using x ticks and by dropping a dashed line from the point down to the x-axis. I decided to write a ...
2
votes
1answer
64 views

Help for using mylatex or mylatexformat?

I have several document of the form \documentclass{article} \usepackage{package1} \usepackage{package2} \usepackage{package3} \makeatletter % some macros \makeatletter \begin{document} \input{...} ...
3
votes
1answer
75 views

A new environment for the lower part of a tcolorbox

I would like to use an environment for the lower part of a tcolorbox instead of just tcblower command. I've tried with following code but it fails. \documentclass{article} \usepackage{tcolorbox} ...
2
votes
1answer
77 views

How can I label / reference description items that contain macros by name?

This question is related to Reference name of description list item in LaTeX, because that is the same as what I am doing. The answer provided there works in most cases, but I found a case where it ...
1
vote
2answers
82 views

Assigning variable a math code

I want all s2 words inside of my large text be automatically recognized as $\rm s^2$, so that when I have numbers of constants such as 9.8 m/s2, they will be automatically recognized as 9.8 m/{$\rm ...
3
votes
2answers
84 views

In Beamer, how can one have strikethrough text in the author setting (defined by a command) in the preamble?

I have some beamer slides for which many commands are defined in the preamble before the document environment. The author setting is defined by an author variable which contains strikethrough text ...
1
vote
0answers
24 views

Why do I get an “extra }” error when using a default argument in a theorem name? [duplicate]

Consider the following latex code: \documentclass{article} \usepackage{amssymb} \usepackage{amsthm} \newtheorem{thm}{Theorem} \newcommand{\Zn}[1][n]{\mathbb{Z}_{#1}} \begin{document} $\Zn[p]$ ...
0
votes
1answer
142 views

symbol for degree celsius in memoir

I am using memoir for writing thesis. I have some issues in using symbol degree. The packages I am using are as below. % \usepackage{lipsum} \usepackage[utf8]{inputenc} % interpret input as unicode ...
7
votes
2answers
506 views

Is it possible to “program” a command wrapper?

I have the following doubt: Is it ever possible to define a command that takes a word as an argument and executes the command with that same name? For instance, something like ...
4
votes
1answer
250 views

Multiple \pgfmathparse and \pgfmathresult

Is it possible to use more than one \pgfmathparse and pgfmathresult in a single macro? In this MWE, I try to use two of each. It did not quite work. The fraction on top should say 10/3, not 0.3/3. ...
2
votes
2answers
60 views

Strange behaviour of \tl_if_eq:NNTF

In the MWE below NewDocumentCommands \myComparison and \myNewComparison both use a control sequence \cookbook_Compare:nn which is fed two tokenlist parameters to be compared. These parameters are ...
1
vote
0answers
71 views

TexStudio won't respond to ctrl shift -

[Ubuntu 14.04 TeXstudio] I'm trying to bind a macro to the ctrl shift - key combination, and even though Tex Studio accepts (and correctly displays) my combination in the Options->Configure ...
1
vote
1answer
68 views

How to use MACRO in bst files

If I put jun in a field, say I put it in the journal field, in my .bib file by hand, when I compile the macro does not seem to substitute it into June as I was expecting. Am I getting wrong what a ...
2
votes
2answers
68 views

Calling macros within \newsavebox

Can someone explain to me how I can include the \begin{lrbox} in the loop? My problem is that I do not know how to call the macro \PMOne or \PMTwo within the lrbox environment. A Minimal example: ...
1
vote
2answers
66 views

Capacity exceeding error with \renewcommand

When I write the command, \in I many times need to add a \nolinebreak and so I wrote in the preamble \renewcommand{\in}{\in \nolinebreak}, but this resulted in an error message {see bellow}. I suspect ...
21
votes
2answers
597 views

What is a primitive, a macro, and how do they compare?

The title pretty much says it all. If it helps, I found myself asking this question when reading this post about \par vs. \\.
0
votes
0answers
36 views

How define a command auto insert some command and enviroment

i have a file like \tag{3.1.1}{ 3 section_name 3.1 subsection_name 3.1.1 subsubsection_name line1 afasf sht sa.fm th saf th adf. line2 afasf th asdfa lg..ag ;ag gasg line3 wfasdfasfsaf. ...
4
votes
1answer
117 views

Macro for Mixed Numbers on Number Line TikZ

How might I change this macro to place the mixed numbers underneath the number line? In this particular example, I'd like 1 1/4, 1 2/4, 1 3/4, 2 1/4, etc. Dunno if this needs a separate thread, but ...
1
vote
1answer
39 views

How to create multi-pass command in a .cls

I have a command that creates some canned text at the top of a file that requires information about the location of an environment I've created. I've got the code for this all put together, and it ...
3
votes
1answer
73 views

TikZ Macro With Multiple Arguments

I am trying to create a simple (hopefully) macro for myself that will make drawing number lines with TikZ more efficient. I can make such lines manually, but since I will need so many similar ...
2
votes
0answers
55 views

Autocomplete in TeXstudio for macro with optional argument

I have a macro, such as \newcommand*{\example}[2][]{#1.#2} defined. TeXstudio adds this to its autocomplete list, which is great, but when I actually autocomplete it shows up as ...
5
votes
1answer
191 views

Why do braces around a single-letter argument of a macro affect its output?

I thought \ul 8, \ul8, and \ul{8} are identical ways of passing an argument 8 to a command \ul. However, they produce different output. Why? MWE: \documentclass{article} \usepackage{soul} ...
1
vote
1answer
28 views

Removing spaces from label generated inside command based on arguments

I have a command which takes two arguments. Inside the command there will be inserted a subsection which also would like to put a label on. The problem is that the arguments might have Spaces between ...
3
votes
1answer
94 views

Saving a value between successive macro calls

I want to save a variable value between calls of a macro, the intention being not to have to repeat a whole lot of parameters in successive calls. It all works as intended if in textmode. If I invoke ...
1
vote
1answer
72 views

Create newcommand with parameters without #?

In understand the basic \newcommand{name}[numberofargs]{functionbody} but applied LaTeX strikes when I try to: \newcommand{\starfootnote}[1]{ \fnsymbol{#1}\addtocounter{footnote}{-1}\arabic} and I ...
7
votes
1answer
145 views

Redefine block environment in beamer

I'm trying to redefine the block environment in beamer so that the itemize/enumerate bullets follow the color of block title instead of structure: \documentclass{beamer} ...
5
votes
3answers
296 views

If Numbers Contain Zeros, Change to Dotted Zeros

MWE \documentclass[a4paper,11pt]{article} \usepackage{calculator} \usepackage{calculus} \usepackage{xlop} \usepackage{pst-node} %%%%%%%%%%%%% Dotted Zero \makeatletter \newcommand*{\pmzerodot}{% ...
4
votes
1answer
79 views

Define different style for \section & \subsection command

I am trying to customize my \section and \subsection command in such a way that they have two different styles. With the following code I am able to draw squared shades around the section numbering. ...
5
votes
1answer
54 views

Add plural to newdualentry from LaTeX/Glossary

LaTeX/Glossary suggets the following command for combining a glossary entry and an acryonym: \usepackage{xparse} \DeclareDocumentCommand{\newdualentry}{ O{} O{} m m m m } { ...
1
vote
1answer
162 views

C-like #ifdef macros in LaTeX? [duplicate]

The C programming language has a preprocessor, which has #ifdef #endif macros that allow to preprocess a source code file before the compilation process. I am looking for something similar. What I ...
4
votes
3answers
103 views

Define control sequences in terms of control sequences

I want to set up aliases for changing control sequences using composed control sequence names. Here is an example. \documentclass{standalone} \usepackage{expl3} \ExplSyntaxOn \cs_new:Npn \name { ...
4
votes
2answers
170 views

Define a new command with parameters inside newcommand

I have read the question and answers about: Defining a newcommand, with variable name, inside another newcommand How to define a macro to create a new macro with a name passed as its argument? What ...
0
votes
1answer
39 views

Using custom commands in preamble

I have a the following command in a resume.cls file \newcommand{\name}[1][]{\newcommand{\@name}{#1}} I try to use it in my tex file with \documentclass{resume} \name{My Name} % use \@name in ...
2
votes
0answers
121 views

LatexDiff: Missing \endcsname inserted [closed]

I have just created a diff file using LatexDiff but the newly created file seems to have issues with the url package, may be. I am getting following error. ! Missing \endcsname inserted. <to be ...
2
votes
1answer
81 views

Defining default vertical space for newline command

Is there a way to alter the default vertical spacing for the \\ line break command? I am aware of the optional vertical spacing parameter for it, as well as the \smallskip,\medskip and \bigskip but ...
3
votes
1answer
79 views

Redefining special characters as macros

I'd like to redefine some special characters as macros. Essentially, I want to tell lualatex to execute some user-defined commands whenever encountering some special characters, such as á, ḿ, etc. ...
7
votes
2answers
150 views

A problem with environment starting macro

For some reason I want a macro \BeginControl such that \BeginControl{\environment} is equivalent to \begin{environment}. I have put together some code. It usually works but there is a problem with ...
6
votes
2answers
85 views

new command is expanding as blank

So I'm trying to import a large list of values that are used throughout my report. However when i do this the results are always blank... \documentclass{scrreprt} \usepackage{csvsimple} % ...
4
votes
1answer
50 views

a macro for putting accent underneath

I've copied a macro sequence from The Advanced TEXbook, p. 446. It supposed to put the accent#1 under the character#2. \def\subaccent#1#2{\leavevmode\vtop{\setbox0=\hbox{#2} ...
2
votes
2answers
50 views

How to prevent page breaks and force indentation in inner paragraphs of a command?

I'm trying to write a diary of a journey I did in the past but I'm facing a problem with paragraph identation and page breaks. I've written the following command (\EntradaDiario) ...
2
votes
1answer
170 views

TikZ node newcommand : pass color as argument

I need to create a row of circles (colored markers) followed by some text. See the image below. I achieve this using the following code. \begin{tikzpicture}[scale=2] \matrix[nodes={minimum ...
2
votes
0answers
64 views

How to create command to make custom Indicator Function

So, I've found this package for common probability items in LaTeX and the very last entry is a "customizable" indicator function in which one simply inputs the variable (e.g. x) and it returns ...
0
votes
2answers
101 views

How to print `n` arguments in a command? [duplicate]

This is what I want to do: \newcommand{\foobar}[n]{% \hspace*{1.5ex}-\hspace{1ex}\emph{#n}\\% } And then use it like this: \foobar {Hello} {World} However this doesnt actually work. I want ...
2
votes
1answer
24 views

hyperrefs have a different spacing when written inside a macro [duplicate]

Let's say I want to make a hyperlink like this: A link is placed \href{www.google.com}{here} to google. Then I decide to make a macro for that: \newcommand\Myhref[2]{ \href{#1}{#2} } A link is ...
3
votes
1answer
42 views

Repeat block without until (or blank line) using algorithm2e

I'm trying to format a "repeat forever" block using algorithm2e. I've found the \Repeat command but this prints an until at the end of my block. I can hide the word until using: ...
6
votes
4answers
129 views

macros with multiple arguments in absence of some arguments

I would like to define a command with two arguments, say \mycommand{arg1}{arg2} in such a way that if the second argument is absent, then it takes the first argument in place of the second one, in ...