{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
2answers
33 views

“List of Lists,” similar to \listoftables or \listoffigures?

While this may seem kind of meta, I'd like some way to create a list of lists at the beginning of a document with labels for each list. Is this easily done? Currently my project is laid out like this: ...
2
votes
2answers
29 views

Put answer as an optional argument for multiple choice

I am using the following code at the moment to make Multiple Choice Questions with the options as the 5 arguments. \documentclass[a4paper,addpoints,answers,12pt]{exam} ...
3
votes
2answers
91 views

Control sequence with arbitrary number of parameters

I want a macro which can generate units consisting of several base units. Let the macro be \unit. For example, I want \unit{kg} to mean \mathrm{kg} and \unit{kg}{m}{s^{-2}} to mean \mathrm{kg \cdot m ...
1
vote
0answers
21 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 ...
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, ...
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 ...
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 ...
1
vote
1answer
46 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 ...
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 ...
7
votes
4answers
141 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 ...
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, ...
0
votes
0answers
21 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 ...
0
votes
1answer
18 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
29 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: ...
6
votes
2answers
137 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 ...
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 ...
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 ...
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][]{% ...
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?
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 ...
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
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 ...
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: & ...
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} ...
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
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 ...
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 ...
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 ...
0
votes
1answer
45 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 ...
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 ...
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 ...
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 ...
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
2answers
126 views

Using macro with optional argument inside macro with optional argument

I am trying to define a macro that has an optional argument that can take a macro with an optional argument as an argument. A minimal example to explain the problem more clearly: ...
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 ...
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 ...
3
votes
2answers
69 views

newcommand for pictures

I am writing my thesis and I want to include pictures via a single command. I am fairly new to LaTeX, so I do not really get it. So far I tried this: \newcommand{\pic}[4]{ \begin{figure}[h!] ...
6
votes
2answers
68 views

Problem declaring newcommand with tikzpicture inside

I plan to put some common commutative diagrams and short exact sequences as new commands in my *.sty file. However, putting this code in my *.sty file \ProvidesPackage{myLayout} ...
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 ...
2
votes
1answer
47 views

Getting sequences, macros, lists, and such expanded(confused)

I'm trying to do some very basic programming tasks(but as usual TeX makes this extremely time consuming and difficult (for me, of course) ;/) The problem is that I can't seem to get LaTeX to expand ...
2
votes
0answers
13 views

Append text to the title [duplicate]

In a class file I want to append an email address to the title. My naive approach was: \AtBeginDocument{ \title{\@title – [email]} \maketitle } But this just doesn't work. If I do ...
9
votes
2answers
206 views

How can I make a command available inside another command's argument?

When I define an environment with \newenvironment, I can use newcommand inside the "before" part, to make commands available to the code inside the environment. Is this possible with simple commands? ...
1
vote
1answer
31 views

Environment that eats up (ignores) text inside it [duplicate]

I want to replicate the environment comment from the comment package: \begin{comment} Hidden stuff. \end{comment} which prints just nothing, instead of using % to comment things out. I can do it ...
7
votes
1answer
57 views

It's safe to ignore tabs and newlines when defining a macro?

I've written several LaTeX environments to format a "use case flow" sequence for a college project. Being a computer programmer, I find quite annoying to not be able to use newlines and indentation ...
4
votes
2answers
70 views

an \underhat and \underwidehat

So $\hat x$ and $\widehat x$ give upper hats of different length, however, unlike \overbrace{} had an \underbrace{}, one sometimes needs an \uhat and \uwidehat. What is the best (cleanest, fewest ...
0
votes
1answer
29 views

Using fully expanded result as a simple string (with citet and \IfSubStr)

I am breaking my head with that problem, without finding anything that could help on Internet : The initial problem is that I write an essay in French but I need to include some articles written in ...