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

When should one place an % at the end of a line to prevent the insertion of unwanted space [duplicate]

I understand that a % character at the end of a line prevents the insertion of a space in the text. However when creating macros I am unclear when you should place a percent sign at the end of a line, ...
1
vote
2answers
56 views

Numbered \newcommand without enumerate

How to add numbered problems within chapters and sections but not with enumerate. Problem must have variable as defined below. \documentclass[10pt,a4paper,oneside]{article} ...
4
votes
1answer
76 views

Extract the last word from a sentence stored in a variable

I want to extract the last word of a sentence stored in a variable, e.g. \thevariable. Here is the minimal example. \documentclass{article} % Function to extract the last word of a sentence ...
5
votes
3answers
177 views

Generate a table with 19 arguments using key-value interface

I'm doing my bachelor thesis, and need to make a table with lots of data. I want to make a macro for that table, since I'm going to use it a few times. Considering egreg's answer in this question, ...
7
votes
2answers
156 views

Why does twocolumn mode break usage of \AtBeginDocument{}?

I've been happily using the multicol package to layout a set of documents that are generated for multiple output formats from the same source. By necessity this moves same code from the document ...
2
votes
1answer
30 views

Nested commands with parametrized names

Inside a command I would like to define multiple new commands. Their names are parametrized by arguments, but they should also be able to call each other during definition. Here is an example: ...
4
votes
0answers
68 views

guess a number proportional to another [closed]

This is a challenging question. I am not sure how to begin coding it, or whether it is easily possible in TeX. I wish to define a command that takes in input of a simple formula such as Z = X x N + ...
1
vote
1answer
46 views

Spacing after alias [duplicate]

I'm not sure whether I am repeating an already existent question or not, but I'd like to know how to approach the following situation: I want to define a macro to be an alias to some word or fragment ...
11
votes
2answers
93 views

split off function for variable as separator

How/Possible to change this implementation of \xSplit so that the separator is a variable filled in at the time of definition (\edef somehow?) or at the actual use of the command?? %based on the ...
5
votes
2answers
90 views

How can I use \XeTeXcountglyphs\font in a pgf \foreach macro?

Problem I keep getting: You can't use `\XeTeXcountglyphs` in vertical mode. Attempt \documentclass{article} \usepackage{fontspec} \usepackage{pgf} \usepackage{pgffor} \begin{document} ...
3
votes
1answer
104 views

Where is \printtoctitle defined?

I can use \show\printtoctitle to get its definition, > \printtoctitle=macro: #1->\printchaptertitle {#1}. l.5 \show\printtoctitle but grepping for it through my latex installation I don't ...
4
votes
2answers
124 views

macro help with $\mathbb{Z}/p^{a}\mathbb{Z}$

I am using \mathbb{Z}/p^{a}\mathbb{Z} many times in my work with variable a, I was thinking can I define a macro like \Z_p^{a} which will give the above result. I tried ...
13
votes
1answer
256 views

How to show keys (ctrl, alt, …, etc.) as fancy as StackOverflow? [duplicate]

In StackOverflow, I can show keys like this: ctrl + alt. How to do the same things in LaTeX?
5
votes
2answers
149 views

Tikz: Latex macros in draw to [in=,out=] and point coordinates

I want to use latex macros in the calculation of the coordinates in a \draw command but that seems not to be possible if both the target point coordinates and [in=...,out=...] instructions involve ...
1
vote
0answers
73 views

Macro passing problem with pgfmath

As a continuation of thread 2010/2014 versions difference: I am trying to decorate program listings with highlighted lines, numbered balls, etc. In 2010, I used a macro which does not work any more ...
2
votes
1answer
34 views

How can I pass variables to \renewcommand from within another command (\DeclareRobustCommand)?

Situation I need to set a few commands and variables based on what language a document is written in. To do this, I pass an ISO 639-1 language code to a command ...
0
votes
1answer
28 views

Names on certificates [duplicate]

I have to make some certificates. The main problem is not the certificate itself but to change names between pages. Can I create a list of names, each of appears once for page?
12
votes
6answers
735 views

command for writing a sequence of numbers

While writing a document with many sequences of numbers (and various lower and upper boundaries), I would like to define a command such as \myscale{1}{6} that would produce: 1 2 3 4 5 6 What ...
1
vote
0answers
67 views

Package xthesis [closed]

\usepackage{xthesis} error messages: command\properpagestyle already defined. ...yle{myheadings}\markboth{}{}\markright{}} command\dedication already defined.{\vfill\end{center}} This errors ...
2
votes
1answer
83 views

CurVe document class: Adjust spaces between entries cross rubric or inside certain rubric without \vspace

I am using CurVe document class to create my CV. I want to know if there is anyway to adjust the spaces between the entries (\entry*[...]...) as indicated by the Figure 1. I know I can always put ...
2
votes
1answer
47 views

Textual replacement macros to wrap environment

I want to create simple textual replacement macros for an environment: \def \myEnvStart {\begin{someEnvironment}[enormous list of arguments]} \def \myEnvEnd {\end{someEnvironment}} This doesn't ...
7
votes
1answer
156 views

Macro for pgfplots/gnuplot exponential regression line

I am trying to create a series of plots with exponential regression that are automatically generated from comma/tab separated .csv files and pgfplots with help from gnuplot. When not using macros I ...
4
votes
1answer
88 views

How to control conditional statements within new commands and environments

I'm writing a pretty complicated class to typeset a book based on memoir. One of my commands draws a caption on the preceding verso page, draws content on the following recto and verso pages, and ...
6
votes
3answers
122 views

substitution problem with plain tex

Can anyone please tell me what I did wrong?? I cann't get the second number of tests to work correctly (and the command appears to be the same argument as done manually) \magnification\magstep1 ...
5
votes
1answer
95 views

Repeat geometry / body / object / shape in PGFplots

I depicted a pentahedron by means of the code \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset { plotOptsA/.style={surf,patch,patch type=triangle,shader=faceted interp}, ...
2
votes
1answer
50 views

\pgfplotstablegetelem in \section does not work

I read in some dates with \pgfplotstableread and want to use this dates. The idea is, I want to be able to change its values without having to change my LaTeX code. The following MWE will not compile ...
0
votes
0answers
36 views

Text tool to expand TeX macros [duplicate]

a few months ago I heard of a tool für TeX but I can't find it, so I want to ask you whether you know what tool am I talking about. The function is: Say you have some own macros like ...
2
votes
1answer
50 views

How to define a numeric variable?

Following the Latex wiki page I tried \newcommand and \DeclareRobustCommand: \documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \newcommand{\marginProportion}{0.76} ...
0
votes
1answer
68 views

\textbf does not work insine \newcommand [duplicate]

I'm trying to make a new command, to add autoincrementing numbers to the definitions throughout my thesis. Here's what I have. \newcounter{DefCounter} \setcounter{DefCounter}{0} ...
3
votes
2answers
66 views

new command for nested enumerate with variable arguments

I have some text that I want to turn into a template which looks like this: Extensions: \begin{enumerate} \item[2.a] xyz \begin{enumerate}[i.] \item a \item b ...
5
votes
2answers
135 views

How can I define a macro, so that is does not have to be preceded by \protect in headings, captions etc.?

I tried to define a macro myself, which outputs different strings according to the input variable (like select-case statements in other programming languages). The problem: If I use the code in ...
5
votes
1answer
139 views

LuaTeX: How to handle a Lua function that prints TeX macros

Let's say that I have a Lua function that prints TeX macros: How can those macros be executed during compilation with LuaLaTeX? In the following example, I defined a LaTeX macro that should print a ...
2
votes
1answer
109 views

How can I know if I am inside an equation environment if it's nested with others?

I wanted to define some partial derivative commands that would be \partial y/\partial x if it was inside an inline equation and would use \frac{\partial y}{\partial x} if inside an equation ...
3
votes
1answer
84 views

How to avoid typesetting any cell if a table is empty

Following How can I define a macro that adds a row to a table that has not yet been printed?, I came up with a macro (\AddToTable) that “builds” a table, i.e. appends its argument as the last row of ...
0
votes
0answers
14 views

How to disable a self-made command [duplicate]

Is there a way to disable a self-made command? I thought of the following: %!TEX TS-program = lualatex \documentclass{scrbook} \DeclareRobustCommand{\mycommand}[1]% % {\textbf{#1}} ...
8
votes
7answers
330 views

How to define optional second argument for macro?

I've defined a command which lets me quickly reference to the number (of figure or table) AND page at the same time: Command \newcommand{\kplref}[2]{~\ref{#1}, S.~\pageref{#1}{#2}\xspace} The ...
11
votes
5answers
498 views

Basics of scanning

I'm trying to master the art of scanning text one character at a time. The following is what I've discovered so far. Is this as good as it gets? I would really prefer not to do all those \edefs as ...
6
votes
2answers
105 views

Suffixed macro and uppercase

when I declare a macro with suffix, its use inside a \uppercase commands doesn't work. See the MWE \documenclass{article} \usepackage{suffix} \begin{document} \newcommand{\AcCan}{\emph{Actes des ...
0
votes
0answers
92 views

Customize index with section name, not page number

I would like to build an index where instead of a reference to a page number, I would have a reference to the section name of the term. So this is what I did (but which doesn't work) : ...
17
votes
3answers
1k views

What is the purpose of hash (#) as a special character sign?

I understand the purpose of all special characters, $, &, %, _, {, }, ^, ~, and \, but just except for hash (#). When and why should it be used?
1
vote
1answer
51 views

How to fix the spaces of superscript text

I'm trying to typeset an old bible which has all the verses superscripted. I created a command that produces a superscript number corresponding to the verse number, and then this is increased by one. ...
5
votes
6answers
188 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
2answers
87 views

How to create a custom environment with a listing inside it?

Well consider the following code: \documentclass[a4, oneside,openleft]{book} \usepackage{listings} \begin{document} \begin{flushright}\begin{minipage}{0.9\textwidth}\begin{lstlisting} for (i) { ...
1
vote
0answers
43 views

How to define a simple command for “mark” in an exam paper?

Here is the link for a .cls file. http://phyweb.phys.soton.ac.uk/ugadmin/Staff%20forms/EXAM%20TEMPLATES/su-exam.cls But all I want, is to be able to use \mark. And being able to get a simple total ...
6
votes
3answers
294 views

Parse argument with a number and an optional letter

How to define a macro which takes a string made by number and an optional letter and then branches on the basis on the letter? Since this is an extension of an existing package, it is preferable not ...
1
vote
3answers
92 views

How to add a framed box inside a paragraph?

I'm using little markers in some parts of my text and I wanted to add one of those to a paragraph entitling a list: \newcommand{\hip}{{\color{BlueViolet}\framebox[1.1\width]{HIP}}} ...
17
votes
4answers
957 views

On/Off switch (redefine a macro at each use)

I try do define a macro \onoff, which alternatively prints "on" and "off" each time it's used. For example the sequence \onoff \onoff \onoff would print on off on My first guess would be to use the ...
0
votes
0answers
108 views

TeXstudio does not auto-complete newcommands

I've just updated my TeXstudio to version 2.9. Unfortunately, this was kinda destructive to my ability to efficiently use it. I have a project with file main.tex which then calls (using input{}) ...
14
votes
3answers
281 views

Creating a newcommand with indefinite arguments

I am kind of new to LaTeX. I am doing project which contain resources (formula, solutions to problems, e.g.) i can bring to the Exams day on 16th March. I have been looking for a solution to my ...
1
vote
1answer
127 views

How to get pgfgantt today to be set to the \today macro

I want the pgfgantt chart to automatically update the "today" line so that it always shows \today when compiled. The problem is that though I am using time slot format=isodate and have set the ...