Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [macros]

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

5
votes
1answer
103 views

Why does \renewcommand{\A}{\B} change the value of \C? when \A, \B, and \C are arguments?

I'm very puzzled by the effect of a \renewcommand with two macros as arguments that appears to affect the value of a third macro. This all occurs within a command to which all three macros are passed ...
1
vote
1answer
38 views

Nested xparse Macros

I often have a macro defined with with various optional parameters such as \NewDocumentCommand{\GenericWebSite}{s O{blue} o m e_}{<code>} and want to define a small variant of this macro, ...
0
votes
0answers
59 views

Calling newcommand without \( \) [on hold]

Today I find a file in which a newcommand is called in the main document without \( \); it is the classsicthesis template. If I insert \( \), the result is different: \documentclass{article} \...
1
vote
1answer
41 views

Problem with using Split inside math mode

Below code is working fine. \begin{eqnarray*} \begin{split} (U\ket{v},U\ket{w}) & = (\ket{v},\ket{w}) \\ || \ket{Uv} || & = || \ket{v} || \end{split} \end{eqnarray*} But if I define ...
0
votes
1answer
49 views

Conditional Macro: if include &, then A; otherwise, B

I want to make a conditional macro. I currently use the line \def\[#1\]{\begin{align*}#1\end{align*}} since I often use align, and don't want to have to type \begin{align*} ... \end{align*} every ...
0
votes
1answer
27 views

Printing labels into file to support editor

I am using the following command to define a custom counter for different things I refer later in the document. \usepackage{cleveref} \newcommand{\customcounter}[2]{% \newcounter{#1} \setcounter{#...
3
votes
1answer
35 views

Update counter in label for newcommand

I am trying to create a new section that automatically updates the counter with relevant label. newcommand-stepcounter sort of does what I am trying to do , but not quite. When I use the code below, ...
1
vote
1answer
29 views

turn pdfximage/pdflastximagepages into a function and use in tikz : ERROR: Missing number, treated as zero.

I feel a bit stupid not to be able to solve this problem, but I can't find a way to turn the following command, usefull to get the number of pages in a pdf : \pdfximage{mypdf.tex} \the\...
0
votes
1answer
12 views

Use of \NoAutoSpacing inside a macro

I would like to locally deactivate the colon character (made active by babel package used with frenchb option). But it appears to not work within a macro: \documentclass{article} \usepackage[frenchb]{...
0
votes
1answer
31 views

A command/macro to use several bibleref styles in a single document

I would like to use several bibleref styles in the same document because some time I need abbreviated reference (e.g. jerusalem style), and at some other places I need to cite a reference in a more ...
3
votes
3answers
136 views

How to automatic increasing row-col in table?

My MWE \documentclass[a4paper,twoside,openright,12pt]{book} \usepackage[left=1.5cm,right=1cm,top=2.5cm,bottom=2.5cm,marginparwidth=0cm,marginparsep=0cm,outer=1cm]{geometry} \usepackage[T1]{fontenc} ...
0
votes
0answers
29 views

\IfStrEq does not work when macro name with ‘@’ is used inside [closed]

Uncommenting \let\a@a=a inside\IfStrEq leads to an error: ! LaTeX Error: Missing \begin{document}. \documentclass{article} \usepackage{xstring} \IfStrEq{test}{test}{% \makeatletter % \...
1
vote
2answers
67 views

cross-referencing text defined by a custom declaration

I've studied a fair number of cross-referencing (or linking) entries here on the exchange, but I haven't found one that meets my need. Apologies in advance if I have somehow missed the solution. I ...
1
vote
2answers
64 views

How to create a direct integral macro

There's a symbol that's commonly used in an area of math I'm working in, called the direct integral, which is often written as \int^\oplus. I think it would be aesthetically nicer if the \oplus was ...
0
votes
1answer
31 views

Specifying font size for the text passed as an argument in a newcommand

I'm using the awesome-cv template and I'm trying to change the following code within the templates .cls file: % Defines writer's mobile (optional) % Usage: \mobile{<mobile number>} \newcommand*...
3
votes
1answer
52 views

TikZ PGF - Minus sign being interpreted as a unit of measure

I'm trying to write a macro that draws a number line given a number of tick marks to use. However, there are a couple of spots in the code where I try to do arithmetic using the argument of the ...
1
vote
2answers
115 views

How can this command be altered to work in more cases?

So the command is as follows: \newcommand{\sumi1ton}{\sum\limits_{i=1}^{n}} I want to be able to generalize this further. For example, if I type \sumj3toQ then it would give me the summation from j=...
1
vote
1answer
50 views

macro to parse latex token as a string

I have a macro (here \mymacro) that receives a command as one of the inputs (specifically a command of type \includegraphics{..}). The macro reads as \newcommand{\mymacro}[4]{% something{#1} ... }% ...
2
votes
1answer
49 views

/Newcommand how to add a picture with specific allignment

In the code you see below I would like to add the option of introducing a picture right after the "employer"/"position" sections. Do you have any idea of how I could achieve that? (package+...
1
vote
1answer
80 views

How do I make a command more generalized?

So the command is as follows: \newcommand{\betahat}{\hat{\beta}} How can I make it so that beta can be replaced with anything. So I can type \yhat and then get \hat{y} or whatever else I might want ...
4
votes
0answers
62 views

Better arrows in math to match tikz-cd diagrams

The underlying problem I find the arrow tip in the Lucida Bright \rightarrow, hence in \to and \mapsto, to be too small, especially at smaller font sizes. Likewise, I find the Lucida Bright \relbar,...
2
votes
0answers
24 views

Keep text as a block and horizontal fill [duplicate]

\documentclass[12pt]{article} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[american]{babel} \...
0
votes
2answers
30 views

using \newcommand with \immediate\write inside beamer

I'm trying to write some strings to an external file using the \immediate\write as in the MWE below \documentclass[a4paper,9pt]{beamer} \begin{document} \begin{frame}[plain] %< comment out for ...
1
vote
1answer
39 views

Define Command/Macro with boolean flag

I'd love to have a command with a boolean flag. That flag is supposed to be used in a conditional statement. I'd love to have something like this: \command -> false \command[flag=...
3
votes
1answer
36 views

pass parameter #1 to minted's \mintinline, when #1 begins with `#`

I noticed the following unexpected (by me!) behaviour, illustrated by this MWE and its output in the figure below: % arara: xelatex: { shell : yes } \documentclass[11pt]{article} \usepackage{...
3
votes
0answers
75 views

Good habits: using \ensuremath to typeset math in text mode

All of this question is about \ensuremath command. I would like to know, possibly from expert users, if there are any counter effects in using math commands in the text via \ensuremath and whether ...
6
votes
2answers
172 views

Fully expand macro argument

I am sure this has been answered already, but I cannot seem to find any answer that explains it in core TeX primitives and that I understand on a token level, e.g. I definitely don't want to get into ...
1
vote
2answers
57 views

How to customize color in tcolorbox having counter

I am new to the LaTeX. I want to customize tcolorbox for custom title with auto counter and background colour as per my choice say light red. Also I want to change the font colour of title and inside ...
3
votes
1answer
159 views

How to find the length of last line of a right to left paragraph

This question is a follow up of my previous question Colors bizarre results with right to left text, \color command works well in right to left text if included at the beginning of paragraph, then I ...
11
votes
3answers
184 views

How to go beyond the impossibility to create a command whose name starts with “\end”

The following simple file gets an error during compilation: \documentclass{article} \newcommand{\enda}{E} \begin{document} dddd \end{document} The error message is: ! LaTeX Error: Command \enda ...
1
vote
2answers
48 views

Pass rest of group as argument? [duplicate]

Is it possible to write a macro, that takes the rest of the current group as an argument? Usecase I want to write a macro that can be used as \section{\TODO Introduction $of$ \textsc{The Topic}} ...
0
votes
1answer
57 views

Using Xindy: Something's wrong--perhaps a missing \item. \cleardoublepage

I want to create a glossary in my article using Xindy. I run this command in the TeXstudio: xindy --language persian --codepage variant1-utf8 --input-markup xindy --module main --log-file main.fa.glg ...
3
votes
1answer
74 views

Adding content to nonexpandable commands without a huge hassle

I'm wondering if there is a package or method to add content around delicate commands without changing the command's name. For example, let's say I want to change \sqrt[#1]{#2} command to yield \...
0
votes
0answers
56 views

LaTeX standard symbol macro [duplicate]

I am looking for a list of standard LaTeX macros which are symbols and available without any packages. Macros like: \LaTeX, \TeX, \slash, \textbackslash, \dots Is there a list for such macros?
1
vote
2answers
84 views

Default value of command [duplicate]

I have the following command: \newcommand{\plusbinomial}[3][2]{(#2 + #3)^{#1}} This command takes 3 parameters and the default value of the first parameter is 2. If I don't want to use the default ...
1
vote
2answers
52 views

Using \ifdefined to show/hidden content

I'm using \newcommand and \ifdefined in the following way: \documentclass[12pt]{article} \usepackage{color} \newcommand{\showcomment}{} \newcommand{\scomment}[1]{\ifdefined\showcomment\textcolor{blue}...
4
votes
2answers
86 views

Define macro whose argument is a word

I need to define a macro whose argument is the next word (the first character after the word should be a blank space, the end of the line, or a punctuation mark from . , : ; ! ?. For example, let's ...
6
votes
2answers
170 views

\newcommand question on “hatting” greek letters in one go

I am working a lot with hatted indices such that \( \hat{\mu} \) A way to make this quicker would be to define the command. \newcommand{\hmu}{\hat{\mu}} but I would need to do this for pretty much ...
5
votes
2answers
75 views

Odd custom theorem behavior when trying to set default value of optional argument

MWE: \documentclass{book} \usepackage{amsthm} \usepackage{enumitem} \usepackage{xparse} \usepackage{hyperref} \usepackage{lipsum} \newtheoremstyle{fctaylor}% name {\topsep}% Space above {\...
1
vote
1answer
26 views

Macro evaluation inside \qrcode{…}

I have two macros. The first, \qrwifidata, generates a string from two arguments and some optional key value. The second, \qrwifi, takes the same arguments and generates a QR code with text overlay. \...
1
vote
1answer
55 views

Combining two macros

Creator of macro Easylist is @egreg (Easylist inside adjustwidth) \makeatletter \newbox\Easylist@box \newenvironment{Easylist} {\par\xdef\Easylist@tpd{\the\prevdepth}% \setbox\Easylist@box=\vbox\...
1
vote
1answer
39 views

Indenting paragraphs within a custom theorem environment

Issue: In my custom theorem environment I would like the beginning line of a new paragraph within the theorem environment to immediately follow the line above it and also be indented: MWE: \...
1
vote
2answers
56 views

Expanding arguments of a macro

For better or for worse, I've defined the page numbers of my appendix using \pagenumbering{arabic}\renewcommand{\thepage}{A.\arabic{page}} If I create a label foo using \label{foo} on page A.21, ...
0
votes
1answer
40 views

Change font size in Siam's Latex macros

I downloaded the Siam's macros and template from Siam's website. I would like to print the current draft of a paper I'm writing with a bigger font size, say 12pt. Unfortunately the usual 12pt option ...
3
votes
4answers
71 views

Pass value from newcommand to siunitx

I have the following MWE \documentclass{standalone} \RequirePackage{luatex85} \usepackage{fontspec} \usepackage{siunitx} \usepackage{datatool} \usepackage{filecontents} \begin{filecontents*}{myfile....
0
votes
1answer
33 views

Conflicts with existing macro when using kvoptions: Undefined control sequence

I am trying to use kvoptions pacakage to allow passing key options to my style file. Here is a MWE of the style file: \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{test} \newcommand{\rtitle}{TITLE} \...
2
votes
1answer
79 views

Inaccurate hyperlink to customly defined theorems

I used the answer here to help me create a document where numbering for theorems and the like appears on the left. But I would like to be able to reference and hyperlink back to these theorems/...
2
votes
5answers
117 views

How can I condition on the last token?

I would like to write a command \foo which, for the sake of simplicity, does just one thing, which is make sure its argument ends with a dot. Thus both foo{hello world} and foo{hello world.} expand to ...
3
votes
1answer
24 views

Labelling and Referencing Multiple Custom Counters Together

This is what I have. \documentclass[12pt,a4paper]{article} \newcounter{theorem}[section] \newcommand\theorem{\stepcounter{theorem}\framebox{\textbf{Theorem \thesection.\thetheorem}}} \begin{document}...
0
votes
0answers
19 views

TeXnic wont accept and recognize the full path directory of MikTex

TeXnic won't accept and recognize the full path directory of MikTex. I have windows 10 and I downloaded the basic 64 bit version. I took photos of MikTex set up file directory to ensure there were not ...