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

2
votes
1answer
32 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
77 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
47 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
48 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
114 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
50 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
51 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
34 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
49 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
43 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
82 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
51 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
25 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
323 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
132 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
79 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
194 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
76 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
88 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
260 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
49 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
221 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
33 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
61 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
81 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 ...
0
votes
0answers
24 views

Is there a possibility to follow where/when a macro is being redefined

I am currently trying to solve several bugs for witch it would be convenient if there exists a system in LaTeX where you can "spy" on a certain macro. I am interested in where/when a macro is being ...
2
votes
0answers
79 views

advanced LaTeX course [duplicate]

I am looking for some tutorial or video-class or something like that about LaTeX advanced course. I want to know more about macros and the creation of packages. Thanks for the attention!
3
votes
1answer
27 views

index, acronym and sorting, macro expansion

I want to use index together with acro: Whenever I use an acronym, I want it automatically in the index. However, not the abbreviation but the long name! What I did: I created a new command: ...
0
votes
2answers
32 views

Parenthetical clauses with a mechanism similar to csquotes' MakeAutoQuote

I have the following macro for writing parenthetical clauses: \makeatletter \newcommand\incise[1]{% ---\,#1% ...
3
votes
1answer
43 views

Using \newcommand with ellipse in tikz

I want to use some constants, height and width, when creating an ellipse but it won't work with \newcommand. Here is a minimal example: \documentclass[12pt, a4paper]{article} \usepackage{amsthm, ...
4
votes
3answers
119 views

NewDocumentCommand with argument specifiers stored in macro

I am trying to write some macros that in turn automatically generate other macros, depending on options etc. I wonder, if it's possible to use \NewDocumentCommand{\somename}{\standardargs}, i.e. the ...
3
votes
1answer
62 views

rewrite comand like a [key=value] using xparse or latex3 syntax

I've written a macro to use some command like a ltxdoc (\oarg,\meta,\marg) without using the textcomp and ltxdocto colorate and decide the font style with which the angle, brackets and text in ...
2
votes
1answer
48 views

Detect whether there's space before and after macro

My document has a custom macro called \newcommand{\myparenthetical}[1]{[#1]} However, I want to be sure that in the document I always have a single space before and after the macro. I would like ...
3
votes
2answers
118 views

Passing complicated argument patterns to a new command

I am using the nice changes package. Which basically provides three commands \added, \deleted and \replaced. Because of the structure and the fact that the optional arguments it takes, I think it is ...
11
votes
3answers
268 views

Treating the contents of a TeX-style group ({\blah …}) as macro arguments

I am trying to make adjustments to a large document that uses TeX-style macros, like this: {\defun SomeFunctionName arg1 arg2} The \defun macro is defined as \newcommand{\defun}{\tt}. Can I ...
14
votes
2answers
252 views

How to define a wrapper to a command that takes an optional argument?

What is the proper way to define a wrapper to a command which takes an optional argument (such as \chapter)? I mean a wrapper, not a clone, such that we can inject code into the wrapper without ...
1
vote
1answer
31 views

How to pass text/strings from main file to beamertheme via beameroptions or is there an alternative way?

In this and this question I learned how to pass simple definitions like a location from my main file to a e.g. beameroutertheme. However this approach fails for longer strings or text blocks, in this ...
2
votes
0answers
24 views

\ifbeamer@anotherslide and \ifbeamer@localanotherslide in beamerbasedecode.sty

At the beginning of the source file beamerbasedecode.sty of beamer class, two switches are defined: \newif\ifbeamer@anotherslide \newif\ifbeamer@localanotherslide By reading beamerbasedecode.sty ...
5
votes
1answer
53 views

Unused \setbox0 in beamerbasedecode.sty

Inside the source file beamerbasedecode.sty of beamer package, there are the following lines: \def\beamer@stoptexts{| stop:0| } { \catcode`\|=13 \catcode`\:=13 \catcode`\,=13 ...
1
vote
0answers
29 views

How to include input filename in error message?

I want to add an error message to a class I'm building for when the user (which will generally be me...) forgets or messes up a macro call sequence. I can do this: ...
2
votes
1answer
47 views

Disable some xunicode macros in case of T1 font encoding?

I was hoping that, except for inputenc/fontenc versus fontspec, old .tex files encoded in UTF-8 could be used without changing anything with either pdftex, xetex or luatex engines. But the following ...
0
votes
0answers
41 views

script to create a table with multiple rows

I'm wondering how to quickly put a bunch of data into a table. I have a rather basic knowledge so I'm asking for a way to read in data by the following format: It has 4 columns, first is formatted in ...
2
votes
2answers
121 views

Why is this macro putting an element of a table on the wrong row?

Consider the following MWE: \documentclass[a4paper,10pt]{article} \newcommand{\macro}[2][]{% & something & #2 & #1 \\ } \begin{document} \begin{tabular}{lccc} \macro{3}{4} ...
7
votes
3answers
106 views

Use the result of FPeval to color a table cell

I am trying to give a table cell a grayscale color value based on it's numeric value. So far I have the following code \documentclass{article} \usepackage{fp,xcolor,colortbl} \FPeval{\resb}{0.5} ...
6
votes
2answers
148 views

How to typeset the percent symbol inside \detokenize?

I am writing some personal notes about R programming. I defined a macro to typeset R functions and operators using a different font style and color: \newcommand{\rtext}[1]{% ...
8
votes
2answers
320 views

Is this sacrificial command a good idea?

I have this command: \newcommand{\name}[1]{\edef\name{#1}} You first call it as in \name{Don} and afterwards you can refer to Don using \name. Is this an accetable way to express a constant that ...