{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
1answer
27 views

Beamer renewcommand

I am doing a presentation using the beamer class and I want to declare a new command, which shortens the following thing: \textsuperscript{1} to \up{1} I did this while using scrartcl with ...
3
votes
1answer
76 views

How to make a list of used custom macros

I used to have a separate file where I store my custom macros. It is nothing more than a huge list of \newcommands and \NewDocumentCommands. Now, I have a little note that I would like to share with ...
3
votes
1answer
43 views

conditional loop printing text and icon

I'm new in the Latex world. I'm writing a little guide and I've choose Latex, in particular Texmaker for writing it. I'm trying to do a loop for printing some instruction as File -> Save as -> Ok. ...
3
votes
1answer
409 views

Misplaced alignment tab character with eledpar's \stanza in command argument

I tried defining a command to enter parallel text/translation with eledpar to avoid having to write all the code for parallel typesetting (both for code clarity and because I'm lazy). So I did try ...
3
votes
1answer
23 views

AucTeX insert-environment C-c C-e (no label prompt)?

Does anybody know how to configure Emacs or Auctex such that when you insert an environment for example with C-c C-e equation RET? Avoid having to type RET for (Optional) What label? question? Or ...
2
votes
1answer
170 views

Copy to clipboard using Javascript macro

I'm pretty inexperienced with Javascript, especially within LaTeX, so I'd like some pointers, guidance or even an MWE of my proposed "button": I want to create a button to copy data to the system ...
0
votes
0answers
20 views

Manipulating the output of \footnote

This is in a way a generalization of my earlier question Footnotes (e.g. citations) in the footline of beamer frames? Generally, I would like to know which macros (La)Tex uses to process footnotes ...
0
votes
1answer
19 views

Custom citing command. Bibtex key as parameter to \newcommand

I'm new to LaTeX and I want to define an auxiliary command for citing. What I would like to achieve is a \newcommand or similar that takes a BibTeX parameter such as paper and produces the same output ...
4
votes
2answers
63 views

Using set list with pgfplotstable

I am trying to create a new column in a table using the set list option, but it will not expand the list when stored in a macro. I've tried \expandafter in various locations with no joy so far. ...
3
votes
1answer
60 views

Redefining a command and special character

I am trying to redefine \v command (wedge above character) to do what \vec does in mathmode and preserve \v in a command called, say \hac. This code works perfect \documentclass{article} \let\hac\v% ...
2
votes
1answer
69 views

Modify the @tufte@margin@float environment to automatically align floats

The Tufte classes provide the @tufte@margin@float environment which is used for tables and figures, but its result it's not automatically aligned with the text. The \marginnote command provide a ...
6
votes
1answer
48 views

testing parameter values with \ifx

Let's say that I would like to redefine \@seccntformat so that whenever the section counter is printed, it is prefixed by Section, but other counters should no be changed. Here is my failed attempt: ...
3
votes
1answer
75 views

How can I redefine the chapter command to display additional text below the title?

I'm relatively inexperienced with Latex. I'm using the Memoir class and I've been trying to develop a custom chapter style based on Danie Els' BlueBox style (the source for this is given on page 46 of ...
1
vote
1answer
43 views

A dynamic variable as content of a glossary entry

Based on the macro defined here, I would like to use it to create a glossary with a variable in the description. Here is my MWE: \documentclass{article} \usepackage[utf8]{inputenc} ...
8
votes
1answer
74 views

How to rename an existing command?

I would like to know if renaming a command is possible in LaTeX. For instance, could I change the \section by \sec ? I read that some people used something called "alias".
1
vote
0answers
30 views

What is the meaning of \+ in doxygen-generated latex?

When compiling a software reference manual with doxygen and latex output, I get the following error: ! Undefined control sequence. l.2 ... Modular System for Shelves and Coasts (M\+ ...
0
votes
0answers
16 views

Include SVG aligns/centers different when used with “newcommand”? [duplicate]

this is my first post in this forum, but i have been here a thousand times, enjoying the high-quality answers to often also good quality questions. So i try my best to also provide all needed ...
4
votes
1answer
41 views

How to know if page is empty

Looking for macro to know if the current page is empty , and opening new page if were not as well. Is there any idea to do that? example in this MWE \documentclass{article} \usepackage{tikz} ...
2
votes
1answer
45 views

macro to showcase newly defined macros

I have the following MWE which takes an argument and prints it verbatim. I have obtained the code from this answer. \documentclass{article} \makeatletter \newcommand{\myverb}{% \begingroup % ...
1
vote
0answers
25 views

Macro for textinput without any formatting [duplicate]

Is there a LaTeX macro that just compiles whatever I type into it? Something like \text or \textnormal. I want to display a LaTeX code inline without any formatting, but don't want to escape ...
49
votes
3answers
1k views

Advantages and disadvantages of fully expandable macros

As I currently understand them, fully-expandable macros are analogous to pure/effect-free functions in functional programming. Correspondingly, things that are not expandable, such as \def, are ...
31
votes
7answers
6k views

Conditional typesetting / build

Let's say I have .tex file which is a set of problems and solutions, of which I want to make two pdf files, one which includes the solutions and one which doesn't. so I need to build the .tex file ...
0
votes
0answers
25 views

Output command arguments for spellchecking

I have a longer tex file which contains text in different languages. The languages are highlighted in different colors, e.g. {\color{blue} some text in french } {\color{red} some text in ...
31
votes
7answers
8k views

What is the recommended way to assign a value to a variable and retrieve it for later use?

What is the recommended way to define a variable inside a document and retrieve its value later? I've googled several different solutions, usually about ~10 lines long. I was wondering, that there ...
3
votes
1answer
41 views

text inside tikz node which can skip to an other

I would like to put text in a mini page with fixed length inside a tikz node using \sbox , if the text skip a specified length (10cm) it will be saved in an other \sbox and used inside a tikz node ...
0
votes
1answer
15 views

\newcommand to create a command with optional arguments

In Latex, I always use \mathbb{something0}_{something1}^{something2}, wheres sometimes 'something1' or 'something2' can be empty. So I had the idea to create a newcommand using the \newcommand. So I ...
10
votes
2answers
133 views

Passing command output as a parameter to the other command

I created some kind of switch statement with a help of \ifthenelse command. Now, I would like to pass its output to another command. In my example I want to colorize each sentence with a color ...
8
votes
2answers
71 views

Package csquotes does not seem to work within a mdframed box defined via a macro

If I define a macro which uses a mdframed box, this seems to disable csquotes (red box). But using mdframed directly (i.e., without defining it via a macro), then the csquotes package can do its job ...
8
votes
1answer
277 views

Does \Twoheadleftrightarrow exist? How to write my own?

I'm a LaTeX newbie. I am writing a document in which I need to have a two-headed bidirectional arrow. Two-headed like \twoheadleftarrow, bidirectional like \leftrightarrow. Is there any package that ...
2
votes
2answers
89 views

redefine starred command \section*

with \usepackage[explicit]{titlesec} I have defined \section like \titleformat{\section} {\ttfamily\Large\bfseries\color{red}} {\thesection} {1em} {#1} i want to redefine the starred ...
6
votes
1answer
108 views

Are (La)TeX macro/command names restricted to ASCII code characters (letters)?

Perhaps this question has been asked already, but my search efforts were unsuccessful. Is it necessary to have ASCII characters (i.e. letters basically [a..z,A..Z], special characters such as \( etc ...
6
votes
2answers
180 views

macro that deletes whatever symbol follows after the code and leave no space

How would the following macro X be defined in TeX? word in previous sentence?\macroX . Next sentence gives output identical to word in previous sentence? Next sentence The motivation: a period ...
4
votes
1answer
100 views

Best practices for multilingual open-source book?

I'm writing an open-source book in two languages (English and Russian) and there are volunteers who would like to help with translation to other languages. My first idea is simple: let there be ...
4
votes
1answer
46 views

Arbitrary positioning in math mode without size restriction

In the MWE below, are all general methods, of achieving arbitrarily shifting of symbols up or down or left or right in math mode, represented? If yes, that is the answer. If no, what good methods are ...
3
votes
2answers
54 views

Problems in expansion of a setcounter macro (Use of \csname doesn't match its definition)?

Followup to Split the reference counter for any numbered item (like with subequations) : I was trying to make a generic subanything macro, and I fail miserably - see MWE below for what I get as error ...
6
votes
1answer
80 views

Execute a command automatically for each Page

my code save groups inside environment topr and topl to two sbox , the command \border draw a frame devided into two parts and put in them the two sbox , here is my MWE \documentclass{article} ...
3
votes
3answers
447 views

Writing bold small caps with mathpazo package

The URW Palldio font (mathpazo package) does not provide bold small caps. To get round this issue, I'd want to make a macro to use small caps usually and normal caps in bold text. I tried this code: ...
3
votes
1answer
31 views

Replacing some macro tokens in a list before \write ing

I'm trying to hack a bibliography package (amsrefs), and fall into the following problem. I'm trying to convert the amsrefs format back to .bib files. This doesn't quite work, because strings get ...
0
votes
1answer
47 views

Graphics: Moving Images and aligning with text

So currently I have this code written out: \begin{figure}[ht!] \includegraphics[width=60mm, scale=0.3]{titanium-distillation-vessel.jpg} \caption{Argon Vessel, containing TiCl$_{4}$ and Mg} ...
2
votes
1answer
44 views

Problem with \edef and CJK

In the following code, it seems that using \edef with CJK contents may fail. (I used pdflatex, UTF8 encoding.) \documentclass{article} \usepackage{CJK} \begin{document} \begin{CJK*}{UTF8}{bsmi} ...
7
votes
2answers
96 views

convert a \newcommand to \newenvironment

I have defined a command as follows \newsavebox{\textsix} \newcommand{\bottomr}[1]{\sbox{\textsix}{\parbox{11cm}{\begin{flushright} #1 \end{flushright}}}} which save the parameter (text) of the ...
4
votes
1answer
51 views

Command with semi-arbitrary characters

Is there a way to define TeX commands with names containing (almost) arbitrary characters, like :, -, _, numbers etc., perhaps even spaces? These are the characters I shall need apart from the ...
36
votes
2answers
2k views

What does \z@ do?

in parcolumns it has \z@ all over the space. I don't see it define it anywhere so I assume it is some internal command or something? I can't really make heads or tails of it though and I can't really ...
4
votes
2answers
47 views

new command using math mode sub index bug

I have defined the following command \newcommand{\gsubselector}[2]{$s_{#1,#2}$} and I'm calling it from a document in the following way: ... \gsubselector{a,i} : \gsubselector{b,j} there is ... ...
2
votes
1answer
110 views

Command to gray words

I would like to create a macro in LaTeX to have the following effect (gray parts) on some text: I would like to have something like \gray{Hello} which puts brackets and grays the text. Can someone ...
8
votes
3answers
176 views

Is it safe to “renewcommand” \SS? (Which packages use \SS command?)

I've tried to set \newcommand{\SS}{\mathcal{S}} in the preamble but I've discovered that this command is already defined. So, I tried native command on my code and I've found that it is a "simple" ...
2
votes
1answer
66 views

How do you define a command for use in a tikzpicture environment?

I want to define an environment for the tikzpicture environment which defines tikz specific commands. Here's an abbreviated example for a UML environment which defines a \Class command): ...
2
votes
1answer
29 views

How to define macros for paths to be used by biber?

I want to use a shortcut to define the paths of my bibtex files and I'm using biblatex and biber. I would like something like: \addbibresource{\myPath{biblio.bib}} I tried in several ways i.e. ...
7
votes
1answer
278 views

What generically CANNOT be compiled inside an equation environment?

Certain macros or whole environments which are themselves not equations, like whole tikz diagrams can be placed in the equation environment and compile. For example Diagram displayed as an equation ...
8
votes
0answers
92 views

How to pass a LaTeX argument verbatim to lua?

I would like to pass an argument verbatim from LaTeX to lua including LaTeX commands and end of line characters. The example below takes care of the former issue, but not of the latter. Is there a ...