{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
25 views

How can I keep everything within a variable/macro on the same line?

I know there are various techniques to keep things on the same line. I have a two-word variable input. For example, Settings App. Let's say there are a group of apps, and I would like them always ...
1
vote
1answer
34 views

TikZ: cannot extract coordinate from intersection point

I am applying the solution proposed in this answer in order to automatically draw a vertical line at the point where to functions intersect. That solution implies creating a new commands that receives ...
2
votes
1answer
45 views

Macro to auto-convert english quotes (“”) to french («»)

French quotes can easily be obtained using \og and \fg commands. Although this is perfectly fine, it's not very intuitive to use them when typing. Is there a way to make latex automatically ...
4
votes
2answers
126 views

\bold in math environment

Having forgotten the command to make text bold in math mode I naively tried $\bold{bold var goes here} these maths symbols are not bold$ and it worked! I became immediately suspicious as I know ...
7
votes
2answers
65 views

read and write commands to auxfile

I have a problem with the aux-file. According to some posts here on Tex-Exchange, the aux-file is read at the beginning of the document (is this at \begin{document} or \documentclass? I wanted to ...
2
votes
1answer
27 views

Modifying command globally from within command

I've seen a couple of somewhat similar questions, but none with similar construct or -- I'll be honest -- none with answers I've been able to understand well enough to adapt to my situation. The ...
4
votes
1answer
53 views

Why does having an empty definition, {}, when defining a new command execute whatever is between the brackets when the command is called?

Here is an MWE: \documentclass{article} \newcommand{\new}{} \begin{document} \new{Why is this printed?} \end{document} Which outputs a document that says "Why is this printed?". My main question ...
4
votes
1answer
56 views

How to call a command in a loop?

there is a code \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage[english,russian]{babel} \makeatletter \newcommand*{\dothis}[1]{% \stringcases {#1}% {% {a}{so you typed a}% {b}{now ...
2
votes
1answer
41 views

Command suggestions in winedt

How do I get command suggestions in Winedt like in texmaker? I have tried exploring the options but couldn't find anything.
15
votes
1answer
583 views

What is the programming term for the command invoking '\' in latex?

I don't think it would be called a delimiter. Is there a specific term for this character? Just to clarify, I'm talking the slash here: \frac{1}{2}
5
votes
2answers
121 views

How do I nest a command with an optional argument?

I'm having problems making a normalizer command that can nest. Here is my code so far: \documentclass{article} \newcommand{\nrml}[2][]{N_{#1}(#2)} \begin{document} $\nrml[\nrml{H}]{J}$ ...
5
votes
2answers
108 views

compare a value from \newcounter to value from \newcount

I searched for this topic, but I didn't find anything, so I hope this isn't a duplicate. I've got the following code: \documentclass[12pt,a4paper]{article} \usepackage[utf8]{inputenc} ...
1
vote
1answer
55 views

Declaring again the same command

I defined a certain command, but now I want to change its definition. I tried to simply change it, but it doesn't compile. What should I do? Thank you very much. EDIT The former command was ...
14
votes
2answers
352 views

Is there any reason not to use \let to redefine a deprecated control sequence to the currently recommended one?

I understand that \bf and \it are both deprecated in the current version of LaTeX. To the best of my knowledge, the correct control sequences replacing them are \bfseries and \itshape. Is there any ...
4
votes
3answers
70 views

Change counter in \edef

When I try to change a counter in an \edef using \stepcounter, I get a whole lot of error messages ("Missing \endcsname inserted"). When I try to do the same with \addtocoutner I get no error, but the ...
6
votes
2answers
90 views

Trouble with patchcmd and double #

I need to patch the following macro from gloss-greek.ldf (polyglossia): \def\greek@numbers{% \let\latin@alph\@alph% \let\latin@Alph\@Alph% \if@greek@numerals ...
1
vote
1answer
90 views

macro: call parameter of level above - double pound ##1 doesn't work

Once again, I have a macro problem. It works almost. I spend a lot of time googling about \expandafter, \noexpand, \unexpanded and others. I used some of them, but nothing lead to the desired result. ...
5
votes
7answers
268 views

newcommand with comma separated argument, and optional arguments

I want to define a command (not with \def) the simplest possible way that it takes arguments separated by a comma, supports an optional argument (the first one). maybe another solution with extra ...
0
votes
1answer
19 views

Kile: How can I insert repeated code snippet and make keyboard shortcut in kile for LaTeX?

To insert figures in LaTeX document I use this code repeatedly: %%%%%%%%%%%%%%%%%%%%%%%%%%% figure environment start %%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{figure}[hb!] \centering \includegraphics ...
7
votes
2answers
1k views

Why is the \bye command not used by LaTeX?

Is there a technical reason why the \bye TeX command was replaced in LaTeX by \begin{document} and \end{document}? I suspect there must be a good technical reason behind this, as otherwise it would ...
2
votes
1answer
26 views

\citefield to include abstract from BibTeX file

I am trying to use \citefield{soure1}{abstract} to include an abstract from my BibTeX file in my document. But, I always receive the message Undefined control sequence.\citefield Here is an MWE: ...
1
vote
2answers
60 views

Adding a tikz picture to every slide in a beamer presenation

I have a tikz drawing I would like to add to every slide in my beamer presentation. Presenly I have to add it manually to every slide - a bit tedious! Is there a way of using a \newcommand to do this ...
1
vote
1answer
68 views

.aux round-trip changing encoding?

I have a situation where I write a simple string out to the aux: \ifinlist{#1}\list {} {\listgadd\list{#1}% write to aux "\macro{#1}"} \def\macro#1{\listgadd\list{#1}} When the \ifinlist ...
5
votes
1answer
48 views

TeXstudio freezes when opening a macro

Since several weeks all my TeXstudio installations show this irritating behaviour: Write a macro like \cite, \input, \SI, \gls, \label, ... Type the opening bracket { As soon as typing the { the CPU ...
4
votes
1answer
44 views

\ifcase suddenly complaning “Extra \or”

For some strange reason, I have an \ifcase which has started to complain "Extra \or" but since \ifcase can have many \ors, how can it have an "extra" one? It's part of a large package, the relevant ...
0
votes
0answers
11 views

Problem using \newcommand [duplicate]

I am using a chemical notation repeatedly so made this new command \newcommand{\MolCState}{$\text{C}^3\Pi_u$} The problem is that in the text when I type \MolCState and the rest of the text the ...
2
votes
0answers
51 views

Automatic lettrine in chapters

I'm trying to get lettrine dropcaps applied automatically on the first word of each chapter. I found some code here: http://dererumnatura.us/archives/2009/02/automatic-usage.html which I've tried ...
3
votes
1answer
52 views

Increment counter with name based on input

I have different counters, and I want to increment them. After I do not want to increment them separately, I wanted to write a macro which does that for me, depending on the input. I have the ...
0
votes
1answer
40 views

\newcommand with intercalated arguments

I want to create a command which works like this: Writting: \w1o2 Should yield: W^{1,2}o(I) I am aware of the parameters use for \newcommand, that would work like this: ...
5
votes
4answers
148 views

Use \newcommand in \newenvironment - content of environment is argument of \newcommand

I want to create an environment, that generates a new command. There are some similar examples on google, but nothing fits exactly. The minimal (not) working example shows best, what I want: ...
2
votes
2answers
62 views

Call command based on comma-separated list

I have several commands, called \cata to \catd. Now I need a command which loops over a given, comma-separated list, and calls the respective command. My current approach is: ...
1
vote
1answer
50 views

Define \def commands which expand non-static

I have two new commands like \def\test[#2]#1{ \test#1[#2] } \def\testOne[#2]{ #2 is given } if I use the following command \test[xy]{One}, it doesn't work, because \test#1[#2] expands to ...
2
votes
1answer
31 views

Colored custom bytefield

I've made a bytefield packet (see picture), and I want to color the field with the field 256-bit RSA Signature : Here is the code I used (from another question) : ...
0
votes
0answers
35 views

Command calls with multiple parameters

I'd like to improve the latex code from a previous answer by using it all along a resumé which I've reproduced below. The MyFrame command have to be called around 20 times but using different items ...
3
votes
2answers
67 views

How to implement a verbatim or null environment using a boolean within \newcommand

I am trying to use a boolean environment within a \newcommand statement to selectively implement a verbatim environment. When I set the boolean to true it should put the "Answer" within the verbatim ...
5
votes
2answers
61 views

Create new command based on an existing one, but with certain characters escaped

I have to escape underscores very frequently inside \texttt, because I use it to mark functions and variables. I'd like to redefine \texttt, under different name, so I could write ...
6
votes
2answers
85 views

Summarize two item levels and combine first level if repetition

I have to write some reports in which I will assign several actions to do to some people. I would like to simplify the creation of an action thanks to some macro and to automate the creation of a ...
1
vote
0answers
23 views

Using newcommand and newenvironment to print a labled tabular [duplicate]

I posted this question as guest with some issues that should be fixed in this version so here it goes. I have the following self defined counter and command: \documentclass{article} ...
3
votes
1answer
59 views

Using newcommand inside newenvironment to print a table

I have the following self defined counter and command: \documentclass{article} \newcounter{usecase}[section] \newcommand{\usecasenumber}{\arabic{usecase} \stepcounter{usecase} ...
2
votes
0answers
49 views

how to use a \global \foreach? [closed]

Is it possible to make a global foreach? How is the correct way to define arguments inside a \csdef command? \documentclass[a4paper,12pt,hidelinks]{article} \usepackage[utf8]{inputenc} ...
3
votes
2answers
40 views

Creating new counter formats on-the-fly with enumitem's \AddEnumerateCounter*

Aesthetic caveat: I am actually using small-caps with hanging figures and not lining. However, in creating a minimal example, I have succumbed to the defaults and created a typographical monstrosity. ...
9
votes
2answers
55 views

\ref with macro as parameter

I would like to write a macro (using Latex3/expl3) that can automatically refer to say plot using several key-value parameters. Here is what I currently have: \keys_define:nn{label}{ Re .tl_set:N ...
1
vote
2answers
46 views

\IfStrEqCase issue using \csname

I want to use \csname inside \IfStrEqCase but I have an error. Here is my code: \documentclass[a4paper,12pt,hidelinks]{article} \usepackage[utf8]{inputenc} \usepackage[brazil]{babel} ...
3
votes
1answer
67 views

Tikz Diagram - Macro Help

I have some code for a network diagram that works when I use it in the body. I've been trying to define a macro so I don't have to write this repeatedly. I have named tikz coordinates defined directly ...
2
votes
1answer
48 views

Forloop with tikz-cd

I am trying to write a macro that (for now) takes as input a number n, and outputs a tikz-cd diagram consisting of n consecutive arrows. However the following code leads to an error: You can't ...
3
votes
1answer
163 views

Why does declaring a command in-document produce horizontal space?

I'm really confused about why there is some extra horizontal space that appears before the second "Test" on my second line: \documentclass[12pt]{article} \usepackage[english]{babel} \begin{document} ...
0
votes
0answers
33 views

What does mbox and fbox stands for? [duplicate]

what does \mbox and \fbox stands for? I felt that it's easier to remember macros when I know what they stand for.
1
vote
1answer
22 views

change caption of multiple listing styles

I want to have different listing environments, each with an own caption. My try was this (vorlage.tex): \documentclass{scrreprt} \usepackage{regexpatch}% http://ctan.org/pkg/regexpatch ...
1
vote
0answers
65 views

Using /csname in

I want to use a smarter solution for a big CSV file with many LocalX columns \documentclass[a4paper,12pt,hidelinks]{article} \usepackage[utf8]{inputenc} %\usepackage[utf8x]{inputenc} ...
13
votes
3answers
327 views

Defining a command to define an asterisk command

I have the following command \defmeta that defines two other commands (one starred and one unstarred) \documentclass{article} \usepackage{suffix} \newcommand{\genericcmd}[3]{#1 #3 #2 } ...