{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
1answer
35 views

Can I inject \xspace in all commands from the complexity package?

The complexity package is a very useful one for a Computer Scientist. Recently, I've discovered the xspace package, which provides the \xspace macro that helps defining macros that do not need the \ ...
3
votes
1answer
54 views

Making a long macro/shortcut in Latex

I was wondering if it was possible to make a big macro, for inserting figures? I wanted it to contain: \begin{figure} [H] \centering \includegraphics[scale=0.8]{#FILENAME} \caption{#FIGURECAPTION \...
2
votes
1answer
57 views

Space lost after \newcommand [duplicate]

I use the initialism "CE" a lot in my thesis, both in an out of equations. I find that the letters are too far spaced for my liking when used in an equation, so I use the \! command to reduce the ...
3
votes
1answer
61 views

Creating removable comment command without extra space

I'm trying to create a command we can use for comments in our document. During development, we want the comments to appear; for production, we want them to disappear. This is a common enough problem ...
3
votes
2answers
184 views

Is there a way to produce \cite{xx} as it is in the generated PDF file?

My thesis is written in many tex files and I would like to have it proofread. However, the proof reader is requesting the thesis in MS Word format. Although the generated PDF can easily be converted ...
3
votes
1answer
67 views

Add content to end of page

is there a simple way to add some content at the end of pages similarly to \AtEndDocument (for example something like \AtThisPageEnd) ? I looked at everyhook and everypage, but it doesn't look that ...
3
votes
1answer
85 views

How can I do unvbox when define macro?

This is another approach to solve the problem in question "How can I write to file part of text between two flags?". I try to "remember" parts of text to use them later. So, I do \newbox\@tmpbox \...
2
votes
1answer
101 views

Creating a heatmap using calculations and tabular environment

I know there exists pgf, and many people uses this to create heatmaps. I however am not allowed to use this package. I therefore want to create a command that enables me to color the different cells. ...
3
votes
1answer
54 views

Define a command that opens and closes an environment

I would like to define a command that, starts (\begin{...}'s it) an environment if not in such an environment, and closes (\end{...}'s it) it if in such an environment, for example: \myenum \...
8
votes
3answers
188 views

How to use \verb or something similar inside a \newcommand

The command \displaygraphics[width-1in]{figure=some_fig.pdf} will display a graphic. Sometimes I want to typeset when I do not have the graphics files available, so I want to do something like: \...
3
votes
2answers
188 views

Drawbacks of csname method to avoid spaces after command

I had a similar problem as this one: Space after LaTeX commands My first attempt was something like this: \newcommand{\satip}{SAT\textgreater IP} This leads to the known Problem, that spaces after ...
2
votes
0answers
48 views

Macro with \afterassignment syntax?

Say for some reason I want to make a macro with input stream behaviour mimicking that of \afterassignment and \aftergroup. Namely, I want to absorb exactly one token from the input stream following ...
3
votes
3answers
45 views

Macro expansion and biocon package

I'm using the biocon package to organize plants in an academic work. I created new taxons as needed in the text, for instance, the family. In the final chapter of the work, I have a large table (about ...
1
vote
1answer
52 views

Macro expansion ordering in tables

I've a large table (about 300 entries). Sometimes, I've a sequence of entries with the same value (for a given column). In such a case, I need to omit the value. All my values are stored in variables ...
4
votes
3answers
201 views

How to pass days to tikz calendar using macros

I'd like to pass to the calendar some day names using a personal command, so user can change the days easily and create a personal calendar. I defined the command \mydays with one argument, which is ...
2
votes
1answer
49 views

Font size macro in tikz font style

I have a set of tikz styles I use for multiple tikzpictures in my document. These styles are in nodestyle.tex. I can optionally modify the size in those styles by doing \newcommand{\trnodesize}{1em} ...
14
votes
3answers
839 views

How to produce this table in latex with inconsistent lists/items?

I want to produce the first two rows of this 5-column table in LaTeX: As you can see it is a special type of tables where we see: itemized lists inside but inconsistently, ie. column 4 all rows ...
3
votes
1answer
52 views

unicode-math and redefine a built-in math command

I'm trying to redefine a math command (let's say \int) so that it will always do more (let's say \int lol) using the following trick: http://tex.stackexchange.com/a/47353/15659 BUT, now I want to use ...
18
votes
4answers
599 views

Detect whether running on pdfTeX or Knuth's TeX for conditional include

Does anyone know a way to detect whether one is running in pdfTeX or Knuth's TeX? I want to be able to conditionally include extra features when a document is being built using pdfTex, but also ...
4
votes
0answers
26 views

Defining a command where the argument could contain percent signs [duplicate]

This minimal example won't compile: \documentclass{article} \usepackage{url} \newcommand{\mycommand}[1]{#1} \begin{document} \mycommand{\url{http://www.example.org/index.php?a=Hello%20World.}} \end{...
0
votes
0answers
22 views

Spacing between custom command and subsequent text [duplicate]

I have defined a custom command for the name of my project; e.g. \newcommand{\projectname}{Gizmo}. When I used the command in my document, I've found that I need to place a ~ after the command in ...
4
votes
4answers
174 views

Expandable macro with loops and advanced string functions?

This might be a very basic problem (as a follow-up to this question) but I cannot figure out how to do it: I need a macro \mycmd{sometext} that yields a string depending on the first character of its ...
1
vote
0answers
84 views

Problem with microtype's `\textls` and math mode [duplicate]

I have some issues with classicthesis' \spacedlowsmallcaps command that I could bring down to the following MWE: \documentclass{scrartcl} \usepackage{microtype} \newcommand{\spacedword}[1]{\textls[...
9
votes
1answer
81 views

Using expanded macro as search pattern for \patchcmd

Is there any way to use the value of an expanded macro as the search pattern for etoolbox's \patchcmd (or xpatch's \xpatchcmd, etc), so that one can have some sort of a "dynamic" patch, by way of ...
4
votes
1answer
53 views

XParse: Command, which creates a command

SE, lately I'm playing around with expl3 and xparse a little and I encountered following problem: I want to create a command which creates a new command -- similar to this post. This is not as hard, ...
5
votes
1answer
68 views

macros - calling a command using an input variable

In the process of a project, I realized it would be helpful if I could do as follows. Say I have a list of different commands (simplified): \newcommand{\AA}{...} \newcommand{\AB}{...} \newcommand{\AC}...
2
votes
2answers
76 views

How to automatically determine the remaining width of the text field in this form?

I have this form made with the aid of hyperref package using the form environment: \documentclass[pagesize=pdftex,DIV=16]{scrartcl} \usepackage{xcolor} \usepackage{hyperref} % \newlength\...
0
votes
2answers
67 views

How to draw a vertical line for separating specific section and content?

While editing my resume, I wanted to place vertical line to separate the section part with the content for the section. Photo attached for clarification. Like this, edited in a sketch app. (...
2
votes
2answers
104 views

How to append data to a global string variable?

Here is a minimal non-working example: \documentclass{article} \begin{document} \let\@var\@empty \newcommand{\append}[1]{ \xdef\@var{\@var #1} } \append{1} \append{2} \append{3} \@var \end{...
8
votes
1answer
194 views

Have a command acting on the environment body

I need to turn this \begin{FOO} my little pony \end{FOO} into this \bar{my little pony} I have tried this: \newenvironment{FOO}{\bar}{} But this seems to only make \bar apply on the first ...
1
vote
0answers
49 views

xparse verbatim argument removing multiple space

I am trying to define a command, using xparse that take as input some verbatim code and cite it using listing. However, the eventual multiple white spaces or tabulations at the beginning of a lines ...
8
votes
2answers
183 views

Modifying fraction macro for in-line text and exponents

There's an amazing fraction macro here* for FontSpec with LuaLaTeX (*: that would be the second macro in that answer, called \unifrac, which I like better than the first "macro"/ using the frac ...
1
vote
0answers
51 views

Escaped characters in labels

I am writing some API documentation, and since I don't like to repeat myself I would like to make some commands and call those for parts that get repeated a lot. However, I am having trouble with ...
4
votes
1answer
43 views

Cut an email if the string size is upper than a value

I've a really long document that I generat with a python script. A big part of the doc uses longtable with an email adress: \begin{longtable}{p{0.3\linewidth}p{0.3\linewidth}p{0.3\linewidth}} value &...
2
votes
2answers
57 views

Automatically make three brackets the same size

I would like to do something like left[ and right], but with an additional | in between which automatically has the same size as the left/right. This comes from the way I denote conditional ...
0
votes
0answers
14 views

All-or-nothing placing of macro-generated text [duplicate]

Given a macro % bold task titles \newcommand{\mypar}[1]{{\bf #1:}} %task decription template \newcommand{\task}[3]{ \mypar{#1} #2 \\ \emph{Solution:} #3\\ } I should like for the text ...
6
votes
4answers
387 views

Defining 'newcommand' without brackets

I know that in LaTeX newcommand is defined as: \newcommand{name}[num] {definition } But I want to define a new command whose argument is not defined between brackets, and it is defined with between ...
3
votes
1answer
56 views

Newcommand with PythonTex

I want to realize pytontex \pyc as newcommand so that I can use it in a generic way. When I use the newcommand I just get some strange "i" (I use it for enumerating the spec variable) and no output ...
0
votes
0answers
42 views

Sorting macros by their first argument

Let's say I have a document consisting mainly of ''task''-macros that are defined as following: % bold titles \newcommand{\mypar}[1]{{\bf #1:}} %task decription template \newcommand{\task}[3]{ \...
6
votes
1answer
67 views

Is there a way to \uppercase greeks?

Here's a sample code, which works for latin math, but not for greek math. \documentclass{article} \providecommand{\bigset}[1]{\ensuremath{\uppercase{#1}}} \begin{document} \bigset d :-) \bigset\...
15
votes
3answers
481 views

Turn tikz drawing into a macro

I have created my own method of drawing a randomly generated closed loop. Here is my code: \documentclass[tikz]{standalone} \usepackage{pgf} \pgfmathsetseed{\number\pdfrandomseed} \begin{document} ...
6
votes
2answers
218 views

Why does \show\jobname result in \jobname and not the name of the file?

Should not the name \jobname expand to the name of the file without the extension? I looked at http://tex.stackexchange.com/a/36967/13552 It says that show results in the meaning of a macro. ...
0
votes
0answers
81 views

Translations from other languages for English with Latex

The problem with doing translations in LaTeX is this: I use the Wordfast program to "record' everything that I tranlsate (Worfast is not a machine translation tool; it is a macro that runs inside Word ...
5
votes
3answers
125 views

Problem with subscripts in custom xparse commands from foreign files

When compiling this code: \documentclass{article} \usepackage{testPackage} \usepackage{xparse} \NewDocumentCommand{\foo}{mm}{#1_{#2}} \begin{document} $\foo A i$, $\fooT A i$ \end{document} ...
10
votes
2answers
248 views

list of all used commands in compiled *.tex-documents

Is it possible to get a list of all the commands used in the compiled documents? I mean, if I use in my various .tex-documents commands such as \emph, \section, \cite, \begin, \documentclass, \...
3
votes
1answer
45 views

Creating a command that concatenates an input string token by token

Using (first of all) xparse I want to create a command like this: \DeclareDocumentCommand{\c}{ s > { \SplitList { ; } } r""} { % do something } It basically should just do the following: ...
2
votes
1answer
37 views

How can I implement xstring's \IfBeginWith equivalently in a non-user-level macro?

I have a string check macro \IfBeginsWith from xstring that is wrapped in a non-user level macro. I have learned here that the wrong approach would be to use user-level commands in a wrapper that no ...
3
votes
3answers
125 views

How to do simple arithmetic with arguments in ConTeXt?

This seems like a simple requirement but after reading the wiki and googling for answers, I can't figure how to express it for ConTeXt. What I want to do is define a macro with two arguments (or one ...
4
votes
3answers
235 views

Variable number of arguments in a command

Code \documentclass{article} \newcommand*\test[2]{#1\textsuperscript{#2}} \begin{document} The player ended as no.~\test{1}{} and her friend came ind \test{2}{nd}. \end{document} Output Question ...
1
vote
0answers
62 views

How can I costumize the ToC for 2 different types of chapters?

I already have ((re)new)defined a 2nd type of the \chapter macro for I have two different types of chapters. But they have one counter, which appears for every chapter in ToC. Here's a MWE: \...