{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
0answers
10 views

How to split a string to figure float with figure name, label and caption?

I am struggling with a shorthand macro that converts a string to a figure. At the end is a working, but unstable version what I am trying to do. The goal is to parse make a command (or macro) like ...
1
vote
1answer
33 views

Argument until non-alphanumeric character

Not sure if this is possible or not... I would like to turn (say) + into a command with one argument without braces. This argument should be everything following the + up until the first ...
5
votes
4answers
125 views

A macro dependent on a parameter

I would like to write a macro privatecomment whose behaviour depends on a global parameter show. For example, in the .tex, I could write \privatecomment{Here is a comment}. When I set show to true, ...
4
votes
2answers
131 views

Need a Macro for Tables - independent of row and column size

I have created the following macro for Table: \newcommand{\createtable}[7]{ \begin{table}[htbp] \begin{tabular}{|p{8cm}||p{8cm}|} \hline \begin{center}\textbf{\cellcolor{Orchid!25}{#1}}\end{center} ...
8
votes
2answers
1k views

Remove spaces after a custom definition

As scientific species names should be written in italic, I have adopted a shortcut to do this in LaTex by creating a definition in the preamble: \def\GM{{\it Gadus morhua~}} Then it's easy to call ...
0
votes
0answers
10 views

Problems with acronym shortcuts (package: glossaries) [duplicate]

I am using the glossaries package to generate a nice list of acronyms. For often used acronyms I defined some shortcuts, e.g. \newcommand{\myshortcut}{\acrshort{myacronym}}. The acronym myacronym has ...
7
votes
4answers
140 views

How can I check whether two control sequences have the same name?

I'd like to test whether two custom control sequences have the same name, regardless of what they expand to or whether they're actually defined. For instance, \ifsamecsname\Foo\Foo should be ...
16
votes
3answers
955 views

create a framed environment for a margin note

What am trying to achieve is the following: Of course, if this can be done so that there is a switch between even and odd pages. Currently I am only interested in the not appearing on the LHS ...
0
votes
1answer
31 views

Increase spacing between item

I am using: Automatically itemize a paragraph to automatically create \item for my bullets and I was wondering how I would go about setting the spacing between each bullet point. The default for ...
0
votes
0answers
20 views

Number format as optional key value argument for LaTeX function

I followed the answer as given in http://tex.stackexchange.com/a/34318/28093 in constructing a function which uses key values. It works fine, but I also want to be able to give the number format as ...
3
votes
1answer
27 views

Refering to colors using numbers

I want to create a command allowing me to colour arbitrary text with a color designed by a number (e.g. 1 = Green, 2 = Blue, etc). To that purpose, I create a first command, giving the name of the ...
2
votes
1answer
23 views

Command \* already defined

I have included the package amsmath as required to defined a new theorem/corollary (without number), but I keep having the following error: ! LaTeX Error: Command \* already defined. Now, ...
5
votes
3answers
181 views

Drawing an oval around Text using postscript in latex and also create a macro for the same without tikz package

The solution is simple when I use packages like tikz. But I am not supposed to use packages. I need to use post script in latex. I am trying to draw this oval using two lines and two curves in a macro ...
34
votes
2answers
3k views

Why Different Commands for Seemingly Similar Tasks?

Take a look at the following list: \textit, \it, \emph, \itshape, \mathit \textbf, \bf, \bfseries, \mathbf ... One might say, for instance, that: \mathbf and \mathit are for math mode, while the ...
0
votes
1answer
17 views

Annotate / plot triangle with slope in PGFplots log log axis environment

As a follow up question on the question posted at Annotate / plot triangle with slope in PGFplots axis environment, how do I do this in a loglogaxis? So, given a relative position in the loglogaxis ...
2
votes
1answer
34 views

'Dimension too large' in `loglogaxis` plot

I constructed a macro to annotate slopes of graphs by means of triangles in a loglogaxis. It works fine for small slopes, but for large slopes I get a Dimension too large error. Minimum working ...
6
votes
2answers
136 views

What is the difference between \@@par and \par?

In LaTeX internal code I came accross \@@par. How is this different from \par or \newline. When should I use \@@par if I am writing a package or class file? In general, there are so many other ...
2
votes
1answer
28 views

About making 4 by 4 or bigger square matrices

I am writing some notes with a lot of similar big matrices involved. So I wish to use \newcommand to make typing easily. For a 3 by 3 matrix, I can use the following code: ...
0
votes
0answers
14 views

Positioning/ Size of MarginText in CV (classicthesis/curvvita)

I'm trying to write my CV in LaTeX, with classicthesis and curvvita for style format. I've got the following code: \documentclass{scrartcl} \usepackage{marginnote} \reversemarginpar % Move the ...
4
votes
1answer
26 views

Problems using listxadd and xappto

I am a fairly experienced LaTeX user. Now, I am trying to get into learning the internals of LaTeX packages and classes. I do not know much about TeX coding. I thought a good beginning would be to try ...
3
votes
2answers
71 views

Howto: if argument is numerical … else

I'm trying to create a differentiation command. At the moment I have the following: \newcommand{\diff}[1][]{% \def\ArgI{{#1}}% \diffRelay% } \newcommand{\diffRelay}[2][]{% ...
3
votes
3answers
53 views

Wrong axis limits when using `\pgfplotsextra` in `loglog` axis environment?

This is a follow up question on Key names of the axis limits when not set explicitly. The solution as given there works great for regular PGFplots axis environment, but not for a loglog axis ...
1
vote
1answer
52 views

How to ignore/comment out a text passage?

I want to hide a very long LaTeX input text in one passage. If I use % for every line I need too much time to hide all the lines. Is there a command that can hide the text in one single passage?
16
votes
5answers
6k views

\vec{x} but with arrow from right to left?

I have two variables: \vec{x} and another one which is somehow dual to the first. Therefore I would like to symbolize the second with something similar but a leftarrow on top of the x. I already tried ...
2
votes
1answer
17 views

Expansion problem with \newlistof from tocloft package

I try to write macro(s), say \foo, which automatically provides counters and \listofsomething like commands for some generated macros, using a xkeyval package approach for fine tuning of the generated ...
3
votes
1answer
120 views

Multiple Choice Answer Key in exam package at the end of document

I think this is a follow up question to: Print answer key to multiple choice questions I am trying to create an answer key at the end of my exam class document where all the questions are multiple ...
3
votes
2answers
69 views

What is a function's signature? [LaTeX3]

I am trying to understand the interface3 documentation. The LaTeX Interface 3 documentation v. May 20, 2014 and March 1, 2015 refer to Defining new functions using the signature in section 3.3. I am ...
6
votes
4answers
170 views

Defining a macro with a variable number of arguments

I want to define a macro that defines a series of other macros, each of which takes a variable (but in any given document fixed) number of arguments. I know that I can do this using something like ...
0
votes
1answer
29 views

Command to automatically start new row

I need not trivial help. I have a command with parameters. This command fills in and prints the following table: \begin{longtable}{|p{3.2cm}|p{2.5cm}|p{2.5cm}|p{2.3cm}|} \hline Some Text: & ...
5
votes
6answers
166 views

loop and char &

I can't find the problem in this code \documentclass{article} \newcount\mt \newcount\mtt \newcommand{\mttab}[2]{% \mt=0 \loop \advance\mt by 1 \mtt=1 {\loop ...
4
votes
1answer
43 views

Plot instance missing in PGFplots

I have written a small macro to draw triangles with slope in PGFplots axis environments. I try to draw two of these triangles. However, the first one is missing for some reason. How can I resolve ...
2
votes
1answer
71 views

How can I get a count of the optional arguments with xparse?

Question Is it possible to get and store a count of the optional arguments actually passed to an xparse declare argument/environment? Purpose Regardless of the number of arguments provided ...
49
votes
5answers
10k views

More than one optional argument for newcommand

The \newcommand macro allows to use an optional argument for the first parameter #1 with: \newcommand{\mycommand}[3][defaultfor1]{blah blah blah} Is it possible to have more than one option with ...
1
vote
1answer
25 views

Writing to aux - you can't use a prefix with `the character @'

In a previous project, we used the following macro to define requirements, so that they were easy to reference later in the text. \newcommand{\reqlabel}[2]{% \label{#1} ...
2
votes
1answer
71 views

LaTeX command or environment to selectively print one out of several given options

I'm currently wasting my time by trying to create a proof-of-concept class to show that writing our university's curricula with LaTeX instead of MS Word would have some benefits. Since these curricula ...
7
votes
1answer
101 views

Create itemize-like command

Can I somehow create a new command with this functionality: {\tabcolsep=0mm \begin{tabularx}{\textwidth}{r@{\,---\,}X} where $P$ & power of transmitter, dB;\\ $G_a$ & Gaining, dBi;\\ ...
4
votes
2answers
48 views

inputenc, active catcode and \csnsame

with this MWE, with a non utf-8 engine (like pdflatex) \documentclass{article} \usepackage[utf8]{inputenc} \begin{document} \expandafter\def\csname a\endcsname{toto} \expandafter\def\csname ...
5
votes
3answers
245 views

macro who argument is proxy of next page break or beginning of a new slide

QUESTION: How do I write macros that run a control sequence \C (for example print a figure on the page or slide, a) right after the next page break (or new slide), or b) right before the next page ...
1
vote
1answer
21 views

how understand my variable is vacuum in use of \ifx? [duplicate]

I want use \ifx and do some thing if my variable\myvariableis vacuum . how do it?
4
votes
1answer
32 views

mydots and linewrapping,

Can someone help me improve upon this command? \def\mydots{\leavevmode\xleaders\hbox to 0.40em{\hfil.\hfil}\hfill\kern0pt} I have been using his to fill space between raggedright and ragged left ...
6
votes
3answers
147 views

Problem with newly defined command and special chars

I have the following problem. In my document, I defined a new command to save a few chars \renewcommand{\r}{r_\mathrm{max}} Additionally, since it is Swedish, it makes use of the special char å, ...
5
votes
3answers
71 views

How can I define a command in the preamble with an optional argument for use in macros?

I'm trying to write tags to include document info which can be declared in the preamble then included in a title page using \@institution or \@module, similar to how LaTeX already includes \title{} to ...
0
votes
1answer
44 views

Setting new command in LaTeX for the differential [duplicate]

I am writing a document in LaTeX and since I use quite often the command ${\rm d}$ for inserting the differential in the integrals , I decided to make a new command and insert in the preamble. I ...
4
votes
1answer
42 views

Suppress indentation in custom environment

I have defined a custom tabularenvironment that has a heading for each table. I have managed to get some vertical space between the heading and the table itself. However, the first column of the table ...
11
votes
4answers
317 views

How to do certain indentations

I tried searching for an answer, but franly I'm so new to LaTeX that I don't even know what I'm searching for, so I'll explain what I'm trying to find below. I would like to have this as one of my ...
5
votes
1answer
43 views

Forward command arguments to another command

How can I define a command that forwards arguments to another command? Specifically, I'd like to create a command that forwards arguments to \pdfcomment and adds the author optional argument with a ...
0
votes
0answers
32 views

how learn write macro code in latex? [duplicate]

Some people ask me about how they can learn ti write macro code in LaTeX. But I don't know any books or texts that can help them to learn. I want know if anyone can introduce some good books on this ...
11
votes
3answers
241 views

3n arguments in a macro (n is an even number) for curves whose thicknesses increase or decrease

For some mathematical figures it's nice to be able to vary curve thickness smoothly along a path, to reproduce hand drawn mathematical figures made with inking liners for instance. One way to do it ...
4
votes
2answers
22 views

How to insert formatting directives into a string-appending command?

The \additem command appends an item to a comma-separated list, and \mylist typesets that list. Works: \documentclass {article} \newcommand\mylist {\relax} \newcommand\additem [1] {\edef\mylist ...
8
votes
3answers
197 views

Special behavior if optional argument is not passed

I am looking to define a command (actually, an environment, but that shouldn't matter for the purposes of this question) that does some default behavior, and if an optional argument is passed, does ...