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

3
votes
2answers
114 views

How to patch with \xpretocmd and \xapptocmd a command by applying to it a macro with argument?

Suppose I'd like to patch a very complicated macro, say \autocite. For this, xpatch package is my friend. If the patch consists in applying a modal command which doesn't take arguments, such as ...
1
vote
0answers
39 views

Replace a nested LaTeX command with multiple arguments [closed]

I'd like to replace the LaTeX command \teilseiten{left col width}{left col text}{right col text} by an nested environment. The problem is, that the second and third argument of \teilseiten contains ...
1
vote
1answer
52 views

How to create two \newcommands from one variable #1?

Consider the following code snippets: a) Text to be printed in some document using command \defPrimitiveRoots \Snippet{\defPrimitiveRoots}{Integers with primitive roots}{ Let $n,k$ be ...
1
vote
1answer
50 views

xparse command definition vs \newcommand [duplicate]

Maybe my question is too broad, but I'd really like to know: what is best to use (and why) between xparse command definition (e.g. \NewDocumentCommand) and LaTeX "standard" definitions (e.g. ...
3
votes
1answer
52 views

In expl3, how to reset a seq variable when content is placed in footer or float?

This answer explains how to use expl3 to store a seq variable to place content later in a document. I'd like to write a command that: Writes the first argument to the main flow of the page. Writes ...
6
votes
4answers
79 views

How to make commands that gather arguments and place in later section?

I'd like to roll my own commands that achieve something similar, in principle, to how \index places the indexed term in a later section, or how footnotes place text in a footer. \summaryandextended{ ...
9
votes
2answers
241 views

Where can I look up LaTeX commands? [duplicate]

I am a beginner in LaTeX. There are some commands that I don't understand (for example \mathop and \operatorname). I want to find some material about them, but I don't know where to look. What is a ...
1
vote
0answers
27 views

How to create command that associates pieces of content to keep them on same page?

I've pieced together a class for my preferred format of Cornell notes, and it allows for floating a summary to the bottom of a page. But, it requires manually choosing the page that will host the ...
2
votes
1answer
74 views

Expansion of \newcommand

The problem I am having is certainly due to my lack of understanding regarding the details of how \newcommand, \def, \edef, \let, etc. work, though I happened to encounter the problem when making use ...
1
vote
2answers
51 views

How can I input only certain columns using macros outside csvsimple?

I want to define a command, like \newcommand \Fruittype {Strawberries} and only input the data from the column that contains it. Can someone help me? \documentclass[a4paper,12pt,hidelinks]{article} ...
6
votes
1answer
134 views

Set the default value of argument as parameter in newcommand

I want to define a command that will emphasis the keywords and add it to the index at the same time. This can be archived by \newcommand{\iemph}[1]{\emph{#1}\index{#1}} But the problem is that, I ...
3
votes
1answer
54 views

How to do simple arithmetic computations with variables to manipulate other input parameters in latex?

I am trying to make a template for my CV. I need to make different color shades for headings, and subheadings many more. I figured out how to make variables in latex such as r,g,b shown in cod below ...
3
votes
4answers
202 views

How could one change the catcodes inside the definition of an environment?

I tried to find a clever and robust way to use non-letter symbols like %, _, ], [ etc.inside the definition of an environment. I tried for example to change [ and ] to letters for using them locally. ...
2
votes
4answers
259 views

Is it possible to use non-letter symbols instead of backslash in the definition of a command?

I am trying to define new commands starting with other symbols instead of the \(backslash) The use of \backslash is not so intuitively for non-experienced LaTeX users. So I would prefer to use ] , [ ...
0
votes
0answers
12 views

How do I use a custom LateX package? [duplicate]

I want to draw some Signal Processing plots in my document, and found a package called dsptricks on ctan. I downloaded the .sty files, copied them to /usr/share/texmf/tex/latex/dsp_stuff, but am now ...
1
vote
1answer
76 views

Use path replacement command inside tikzpicture/pgfplots table

After using the answer of Using \nameref within \path I tried to use that command inside a 'pgfplots' table as file name. Here's the (shortened) code: \newcommand*{\expath}[1]{/Users/jo/{#1}} ...
5
votes
3answers
163 views

Where to define new TikZ commands

I have to start by saying that I am a newbie to LaTeX, let alone TikZ. In order to solve another problem, I found a solution in another question in a comment by Tom Bombadil. He defines the new ...
1
vote
1answer
79 views

Is it possible to get rid off of { and } in the definition of a command?

My purpose is to write simple commands that put graves and other accents symbols above Greek letters. I am facing the following problem: Let say \grave{i} puts the grave symbol above I (for example: ...
3
votes
1answer
29 views

How to put non-return function and return function in \newcommand?

During my work, I came across a need to insert pages from PDF document (which i used \usepackage{pdfpages} and \includepdf[option]{doc.pdf}) and I wanted to add these pages into \tableofcontents with ...
3
votes
1answer
65 views

Redefine norm symbol \| as \left\| or \right\|

I'm currently using the following macro: \def\norm#1{\left\|#1\right\|} Is it possible to redefine \| so that \|\frac{a}{b}\| produces the same output as \norm{\frac{a}{b}}? Why? Not only I find ...
2
votes
1answer
78 views

Redefining command outside math mode

In LaTeX2e, Is it possible to redefine a command, yet have the scope of the redefinition apply itself only outside math mode? For instance, I'd like to redefine \sec to \section, but unfortunately ...
-1
votes
1answer
43 views

How to load different macros for different files

I have a thesis with a common macros file for all the chapters. I would like to not load this file in my cover.tex which is loaded from a thesis.tex file as \input{cover} but after the cover. How ...
4
votes
2answers
192 views

Centered hat over bold letter with subscript in \newcommand

I'm relatively inexperienced with LaTex and I'm trying to use \newcommand in a larger project. I have several cascaded \newcommands that I can't get to behave the way I want: ...
2
votes
3answers
151 views

Macro in texstudio/texmaker to surround selected text with tags

When you use some of the predefined shortcuts in texstudio on selected text, it wraps the text with the appropriate tags(is that the proper term?). For instance, suppose i highlight Hello Worldand ...
3
votes
1answer
92 views

Automatically add \noindent for short paragraphs

Is there a way to activate \noindent to each line which is so small that there is no line break in the paragraph? An example: The code This is a long paragraph: Lorem ipsum dolor sit amet, ...
1
vote
0answers
65 views

HZ typesetting system in plain TeX

How can I use the hz typesetting engine with plain TeX and pdfTeX? I read about it in TUG Vol 36 no.2, Peter Karow article, link: TUG Vol 36 no.2, Peter Karow.
1
vote
0answers
35 views

Why \@M instead of 10000? [duplicate]

Reading code from packages/whatever, I often find commands like \@M, \p@, \z@, \m@ne, \@ne, \tw@ etc. What is the point in using those instead of the (IMHO more understandable) 10000, pt, -1, 1, 2 ...
1
vote
2answers
61 views

Construct and print name lists with macros

I have to print author lists in different places. In the cover the author should be printed as Name1 \\ Name2 \\ Name3 But in other places it should be printed inline. Name1, Name2 and Name3 I ...
2
votes
1answer
60 views

Make brackets appear when I refer to an equation (with the help of \def or \newcommand)

I want to define a newcommand that allows me to write just \ref{Label} instead of (\ref{\label}). I tried \newcommand{\reff[1]}{(\ref{[#1]})} and \def\ref[#1]{(\ref{#1})} but both of them did ...
6
votes
2answers
157 views

A problem with newcommand

In the following code \documentclass{article} \usepackage[usenames,dvipsnames]{xcolor} \usepackage{tcolorbox} \usepackage{tabularx} \usepackage{array} \usepackage{colortbl} \tcbuselibrary{skins} ...
4
votes
1answer
52 views

Is it possible to defer expansion of an object's contents until all content has been created?

I want to provide author-usable macros in my package to store data that will later appear in a table, but it would be nice to allow authors to define the data in that table at any time, even after the ...
1
vote
2answers
92 views

Macros in LaTeX class

I have the following macros in a LaTeX class: \def\labelenumi{\theenumi.} \def\theenumi{\arabic{enumi}} \def\labelenumii{(\theenumii)} \def\theenumii{\alph{enumii}} \def\p@enumii{\theenumi} ...
6
votes
2answers
131 views

How to extend existing macro with \edef?

\edef does expansion, but does not execute the commands. How in the following example make so that \foo will do assignment to \tmp at the moment of its call, not when it is defined? Why \foo produces ...
6
votes
3answers
141 views

How should I /protect this command for use in \csname?

In the process of learning how to use \csname, I'm trying to create a macro that allows one to specify integers as arguments and then will yield some content specific to the arguments, like this: ...
5
votes
2answers
152 views

Defining a command that starts with “@”

Context: I've inherited a mess of latex notes from another faculty member; these are processed by using a home-brew system that does lots of clever stuff ... but that means that I must work on them ...
4
votes
2answers
59 views

Using letter format as parameter for successive macro calls

People! I want to give the letter format, i.e., \tiny, as parameter for a macro \printarray that calls another macro \subprintarray. With the given code below I expect such a result: But I get ...
3
votes
1answer
50 views

Remove \par from string

I have to put a string in various places of a book. This string is stored in a macro \newcommand{\subtitle}[1]{% \newcommand{\thesubtitle}{#1} } \subtitle{The quite long \par subtitle} Long ...
3
votes
1answer
75 views

a \frac{}{} with knobs

I would like to create a variation of iff (A|B or \frac{A}{B}), say A \cirf B and \fric{A}{B} for if of the kind below. It can be done in tikz however that won't scale with the arguments in size, ...
2
votes
1answer
79 views

Distributing a LaTeX2e compiler in .NET application

Is there a way to wrap a LaTeX compiler with a .NET application, so that the wrapper can compile an output .tex file, and visualize the results? Where can I get a compiler (For free, commercial?) ...
1
vote
1answer
49 views

XParse doesn't recognize some of my variables

Based on the comments from my last question have I tried to create a new command using \NewDocumentCommand. However, it wont recognize some of the optional arguments - they just get printed as is. Any ...
0
votes
0answers
42 views

Why does commands with \begin{} and \end{} not work? [duplicate]

Since I use the combination of an 'align' environment inside a 'subequations' environment a lot, I decide to create the following two commands: \newcommand{\asdfa}{\begin{subequations}\begin{align}} ...
2
votes
1answer
39 views

How do I wrap a macro definition in an environment?

I'm creating a style file, and want to store the body text of the abstract environment so that I can put it on my custom titlepage. I could have required that my users enter the abstract as ...
3
votes
1answer
43 views

Changing content of variables in toc (in ConTeXt): nested \def s

I try to define a "variable" for a category. Using it for the first time, the value should be reset until it is set again. This is the desired output: Fruit: Apricot (also in category) Banana (also ...
2
votes
0answers
156 views

How can I migrate commands and environments from LaTeX2e to LaTeX3? [XeTeX]

Sometimes forcing consistency makes things much easier to maintain. The motto "keep it simple" comes to mind. xparse offers the most bang for your buck when it comes to defining commands with various ...
0
votes
1answer
61 views

\hbox cause alignment Error

I have an issue i can't figure it out, i have a definition like \let\rendsplit@old=\rendsplit@ \def\rendsplit@{% \global\setbox\z@\vbox{\hbox{\vbox{\unvcopy\z@}}}% \rendsplit@old% } the ...
2
votes
1answer
61 views

How do I add a newcommand which includes formatting?

Currently I'm using \newcommand{\ps}{\textbf{\psi}} but this bolds everything after $\ps$. What do I do to get the desired result of inserting a bold $\psi$ when I use $\ps$ ? Thanks
1
vote
3answers
128 views

Renewcommand \textspanish

Let's say I write a LaTeX document that usually is compiled with xelatex (and polyglossia), but I'd like to have pdflatex (and babel) as a fallback (when I send it to someone who might not have ...
3
votes
1answer
64 views

newcommand with an argument behaves differently from newcommand with no argument

When I use newcommand with no argument, I get expected behavior. When I add an argument to my command, latex adds an extra space. Here's an example: \documentclass{minimal} \parindent=0 pt ...
3
votes
1answer
66 views

A way to generate Dynamic command names

I want to save blocks of code/info in a LaTeX file using commands, but I have no way to know how many blocks will be needed. I am wondering if there is a way to create dynamic names of commands so ...
2
votes
2answers
98 views

I want to create a new command for making a table, parameters in the command would fill up the table

For making play cards, I need to make a table of 5 by 5 cells. First row and first column would always be the same. But the other cells would depend off the card. So it would be nice to gave a ...