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

0
votes
0answers
24 views

How to create a specific code listing macro

I am trying to reproduce a macro in latex that would allow to insert code in this format: So there is a header with listing number that is starting from the left side of the document. It is between ...
1
vote
0answers
47 views

How to put a text at the end of the last sentence of a document with xelatex?

I have a lot of documents witch all have to share the same last text. But this text have to follow the last sentence immediately — without line break —. I try to modify the document environment but ...
2
votes
1answer
236 views

Negative phantom inside equations

The following code produces a negative phantom (from the comment in this answer): \newcommand{\negphantom}[1]{\settowidth{\dimen0}{#1}\hspace*{-\dimen0}} However, when used inside an equation like ...
4
votes
1answer
120 views

Single letter macros

In this post I learned that single letter macros purportedly have a significant impact on the typesetting process. For the past n many years I have been redefining letters like '\d', '\x', '\z', and '\...
1
vote
1answer
43 views

Latex won class and macros

I'm writing my own simple template, what I have so far is a new, redefined make title command: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{myclass}[2016/06/22 My custom class] \LoadClass{article} \...
5
votes
2answers
153 views

What's the purpose of nesting a \def within a \newcommand?

I recently found the following piece of code: \newcommand{\ISBN}[1]{\def\ISBN{#1}} Isn't it redundant? What's its purpose? UPDATE I now understand its purpose. I have never seen it before. Is it ...
4
votes
2answers
132 views

Nested Logic Gates

I am trying to get a nand gate to work like the one mentioned in this article, and it takes issue with the ifnum being fed a single integer rather than a pair of integers with an equals. When I fix ...
2
votes
1answer
76 views

Renew command not working

I have the following command written in my preamble \renewcommand{\d}{\;\ensuremath\mathrm{d}} but get the error LaTeX Warning: Command \d invalid in math mode on input line 11. This only ...
0
votes
0answers
34 views

Creating macro for double-Sig rune (SS)?

I'm (almost) a complete novice when it comes to TeX, and this question is more for my curiosity than anything else... I've read quite a few books about WWII and the Nazi-German occupation of Europe, ...
6
votes
1answer
124 views

How to remove the space after an empty note in \autocite?

I am currently writing my thesis, and I would like to put a placeholder for "cf." in my autocite like so: \autocite[\cf][]{Author.2016} Reason: in case my mentor wants me to use a citation style ...
5
votes
3answers
112 views

A macro that processes and hides text?

I'm writing a solutions manual for a text. Some of the solutions are only supposed to be visible to the instructor, so I've written a macro \newcommand{\instructor}[1]{} which hides its argument. ...
3
votes
1answer
39 views

indexing woes with macro arguments

I have asked strip last character from parameter if it is 's' and I was given an answer. However, it turns out my case is little bit more complicated. Some of the monsters have hard to type ...
4
votes
3answers
116 views

Separating sub-/superscripts out

I'm looking for a way of separating super-/subscripts (if they exist) from a LaTeX command argument. As an example, imagine you want to define a command that builds multisets from sets by placing an ...
6
votes
5answers
552 views

strip last character from parameter if it is 's'

I have a semantic annotation \monster to annotate mentions of monsters so that they are indexed: \newcommand{\indexMonster}[1]{\index{#1}} \newcommand{\monster}[1]{#1\indexMonster{#1}} Now, most of ...
1
vote
1answer
49 views

Remarks using Changes Package

Using the changes package, how can I create a 'remark', which is displayed in the same markup colour formatting, and included in the list of changes when in draft or normal mode, but is removed ...
3
votes
1answer
225 views

Can I reobtain a command I've overwritten with renewcommand?

I've overwritten the \bullet command using \renewcommand (which in hindsight, was a bad idea...). After using the new \bullet command for quite a while, I've realized that it behaves badly in certain ...
2
votes
1answer
43 views

file ended while scanning use of \path

MWE: \documentclass{article} \usepackage[obeyspaces]{url} \usepackage{xcolor,letltxmacro,booktabs,longtable,tabu} \LetLtxMacro{\oldpath}{\path} \renewcommand{\path}[1]{\color{gray}{\oldpath{#1}}} \...
0
votes
0answers
11 views

Using arguments in \newenviroment together with \caption [duplicate]

I created \newenviroment for "professional tables": \newenvironment{tabpo}[1]{% \begin{table}[!ht] \centering \begin{tabular}{lllllll} \toprule } {% \bottomrule \end{tabular} \caption{Arg:...
4
votes
2answers
123 views

How to define a blank-independent macro

How would I define a macro \test , e.g. using \def\test#1{...}, that can be used in the two following ways? The usage without a blank \test{A}This is some text as well as the usage with a blank \...
1
vote
3answers
55 views

How to convert \textwidth to mm and use the number as a command?

I am trying to convert \textwidth to other units I want and do calculations with the number (without the unit). How does one do this?
0
votes
1answer
63 views

Using counter in csdef

I'm trying to implement a map: counter => string + another_counter: 1 => eq1 2 => eq2 3 => ineq1 ... I use \csdef like this: \csdef{probName\thecntProblem}{\csuse{filePrefix}\arabic{...
8
votes
4answers
186 views

Dynamically filling a grid with TikZ from a data array

I have been trying to fill an grid with "binary" type data, so you iterate through an array that is 2D and these 1s and 0s decide if a location is filled or not. This is my first foray into ...
2
votes
0answers
41 views

\strip@pt\textwidth gives “undefined control sequence”

I'm sure that this is something silly, but I've been beating my head against the statement \strip@pt\textwidth giving "undefined control sequence". I'm trying to modify some drawings in tikz widths ...
9
votes
1answer
226 views

Using {\AA} when \r is redefined

I'd like to use {\AA} to input a capital A with a ring above. However, the document I am writing has to import some definitions which I have no control over. One of the definitions changes \r: \...
3
votes
1answer
54 views

How to correctly create a macro for a table?

I am trying to apply the following answer: http://tex.stackexchange.com/a/72916/25124 What is wrong with this code? I am trying to define a macro to be able to specify a table of 3 columns but whose ...
1
vote
1answer
27 views

Why does embedded \g@addto@macro sometimes fail?

I decided to test my understanding of expansion and embed \g@addto@macro within another three macros. \g@addto@macro \appendmacro \layertwo \activatelayerone From my understanding, the ...
2
votes
1answer
72 views

How to write macros?

I'm very new to TeX and am only learning it to write in MathJax on the math stackexchange. I've just discovered that I can write macros to make it easier to do repeated things, but I'm having some ...
4
votes
1answer
41 views

Package Neuralnetwork label neurons independently

I have a problem which I can not solve. I'm quite new to the world of LaTeX and I don't know much about macros. Heres my problem: I draw a Neural Network using the Neuralnetwork package. I have an ...
2
votes
4answers
185 views

How can I pass a macro to a macro and check for its existence?

I hope this question makes sense. If I wanted to modify the following code to allow the user to pass a macro as the first parameter, how would I do it? How it is: (using pgf) \def\appendtolist#1{% &...
2
votes
1answer
59 views

Can't compile with BibTeX

I'm creating a document in LaTeX with the bibliography in a separated BibTeX file. When I compile the document without any reference to the bibliography it runs correctly, but when I add references ...
1
vote
0answers
56 views

Where is \noident defined? [closed]

As always, I have the following: \documentclass{article} \usepackage[utf8x]{inputenc} %∑ \usepackage{hyperref} %clickable x-ref-s \usepackage{url} %\usepackage{fixltx2e} \usepackage[margin=...
4
votes
1answer
37 views

Ignore undefined key in argument (it's defined in the macro before it's used)

How can I make this macro initially ignore the undefined key fn-special-text in the second argument? It is defined within the macro (because the name is generated from the text of the first argument; ...
4
votes
1answer
58 views

Quarter turns according to coordinate axes in TikZ

I'm trying to implement quarter turn style arguments in TikZ, in such a way that \begin{tikzpicture} \path (2cm,1cm) coordinate (A); \draw[blue,->] (A) [northwestqturn=3cm]; \draw[green,->] (...
5
votes
3answers
379 views

Can I define a macro that accepts everything until the next space?

I'd like to make a shortcut macro to prefix function names in formulae to decorate them in some way depending on the function type. Using "normal" macros would lead to an abundance of braces and I'm ...
4
votes
1answer
35 views

Abbreviations for align

I know from the Technical notes on the amsmath package that it is not possible to introduce direct abbreviations like \newcommand{\bal}{\begin{align}} % doesn't work \newcommand{\eal}{\end{align}} %...
6
votes
1answer
40 views

LaTeX3 Regex using control sequence

I'd like replace some words/characters using l3regex on a arbitrary variable. Instead of doing this \tl_set:Nn \l_myname_tl {Hello} \regex_replace_all:nnN {(\w+)} {\1 World!} \l_myname_tl which ...
7
votes
3answers
179 views

Draw circle in TikZ by specifying endpoint and distances instead of angles and radius

In the classical arc command in TikZ, we specify an endpoint of the arc, followed by the initial and final angles, and finally the radius. I would like to create a macro (if it doesn't already exist) ...
11
votes
1answer
277 views

Solution to 'Multiple PDF generation with one tex file' does not work anymore with TeXLive 2016

The solution in Multiple PDF generation with one tex file worked with TeXLive 2015 and is now broken in TeXLive 2016, at least on OS X El Capitan. Minimal Example: \documentclass{article} \ifx\...
1
vote
2answers
87 views

Automatically generate new commands and keyval definitions

I would like to automatically define new commands and keyval definitions anytime that a command beginning with the prefix \fn is used within a string. Part I below is the stub that needs to be ...
0
votes
0answers
13 views

Variable name space problem [duplicate]

I have a problem with defining a variable in latex. Here is the deal: I create a variable containing a string like this: \newcommand{\company}{{Company Name}} It works, but the problem is when I ...
5
votes
4answers
194 views

Macros that define other macros, which also define other macros

I would like to define a TeX 'macro-building' command (let us call it \buildmacro) that takes as argument a string of 'normal' characters (e.g., Title) and which satisfies the followings: the ...
7
votes
1answer
72 views

Macro overloading, catcode redefining… or how can I parse XML with TeX?

Given this code that barely parse XML and print it as SXML (s-exp XML, aka lisp-style XML, aka XML-with-parenthesis): \catcode`@=11 \let\@xp\expandafter \def\@makeletter#1#2\@nil{\catcode`#1 \ifx\...
6
votes
2answers
68 views

Latex3 equivalent csname endcsname

I would like to know how to create dynamic named macros (in a loop) in Latex3. Everythings ok in LaTeX2e. I look to something equivalent to that code with expl3 \stepcounter{N} \expandafter\def\...
3
votes
1answer
70 views

Don't break item (without disappearing footnotes)

I am trying to keep items (used within a command) from breaking internally, but the solutions I've found end up causing the footnotes to disappear. Any advice on how to keep the footnotes alive but ...
1
vote
2answers
55 views

How does one detect if the next char is ^? [closed]

How do I do this? Using \@ifnextchar^{command1}{command2} fails to work. What should I do instead to detect ^? UPDATE. There turned out to be no problem with the command, just a conflict of names ...
1
vote
1answer
39 views

newcommand defined on multiple lines creates extra white space

When I define a \newcommand over multiple lines, I get unwanted white space in my output. How do I make it so I can write a long command, but still make it readable, without getting the extra white ...
1
vote
1answer
46 views

Create an automatically command for: $\Rightarrow$

Is it possible to create a quick command for $\Rightarrow$, because when I write a math paper I use often this: $\Rightarrow$. I know that the simple command \Rightarrow it can be shortcuted, but $\...
7
votes
2answers
331 views

How does LaTeX renders a \div?

This is a follow-up question to this one: How can I get a "divide by" symbol with \usepackage{physics}? In the referenced question the OP asked how to \undef a redefined \div. I want to ...
1
vote
1answer
48 views

How to repeat text without duplicating it?

I have defined a command for writing down 'requirements' in my document. It automatically styles and numbers it and creates a label to which I can refer to get the number - really nice. However, ...