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

Problem with microtype's `\textls` and math mode

I have some issues with classicthesis' \spacedlowsmallcaps command that I could bring down to the following MWE: \documentclass{scrartcl} \usepackage{microtype} ...
9
votes
1answer
62 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
36 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
26 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}{...} ...
2
votes
2answers
39 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} % ...
0
votes
2answers
20 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
76 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 ...
7
votes
1answer
156 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
29 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 ...
6
votes
2answers
125 views
+50

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
30 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
39 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
45 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
13 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 ...
5
votes
4answers
247 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
28 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
40 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
58 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 :-) ...
15
votes
3answers
392 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
206 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
68 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 ...
5
votes
3answers
107 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} ...
4
votes
1answer
152 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
42 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
36 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
105 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
144 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 ...
2
votes
0answers
48 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: ...
3
votes
1answer
39 views

Arithmetic operation between command arguments and latex parameters

I'm defining a new command that places two images one next to the other and I want to add an horizontal space between the two images which corresponds to one third of the space that remains blank. The ...
2
votes
1answer
22 views

Declaring multiple commands

I want to declare a series of commands \SA...\SZ as demonstrated here -- I want to avoid the additional \loopS command that is used though. However, merging the two lines (L1 and L2) into one (L3) ...
1
vote
1answer
42 views

How to patch a starred environment

I would like to translate my approach to center all figure environments to figure* environments. How? \documentclass[peerreview]{ieeetran} \usepackage{xpatch} % ...
0
votes
1answer
55 views

Distinguish odd and even pages in a same paragraph

I have some margin notes in a text, and want them to be aligned in different way according to the odd or even pages. I created this command : \newcommand{\notemarge}[1]{\ifodd\c@page ...
6
votes
1answer
261 views

How to make a package play well with others?

I have an ever growing preamble and it contains commands like \su and \so for the special unitary and special orthogonal group algebra, just \mathfrak{SU}. Then later I wanted to use the soul package ...
4
votes
1answer
60 views

Reset counter via macro with \ifcase in Plain

I am not able to reset a counter to zero using a macro in Plain TeX. This code uses \ifcase and the counter animalnum to output one of a list of animal names, incrementing the counter each time it is ...
16
votes
1answer
358 views

Learning to use xparse

I'm learning to use xparse to build commands with optional arguments. But I'm having problems: I want to make a command called \topcat with output: \mathcal{O} if no argument is specified ...
4
votes
3answers
212 views

How to change the output of a command if it has been called already?

I want to create a command that changes its output the second time it gets called. For example, I want it to yield 1 the first time it's called, and 2 the second time: \newcommand\mycommand { do ...
0
votes
0answers
43 views

Simple homework template doesn't work

I want to make a simple template to do my homework in a textbook where \chap{1} becomes \section*{Chapter 1} and \begin{part}{foo} becomes \subsection*{foo} \begin{enumerate} (so \end{part} becomes ...
6
votes
2answers
179 views

double sqrt (surd) symbol

I want to define a macro that prints two adjacent sqrt symbols. (Notation from Cauchy's analysis book). I get something close but the spacing is changing depending if there is a number before it. ...
2
votes
1answer
38 views

How to define space as a variable?

I want to define a command that makes vertical space like \\[30pt] variable. I want to define the string between the brackets so that it is variable like 20pt or 1.5cm. Thus I would be able to define ...
1
vote
1answer
44 views

Date translated to Chinese

The English dates are strings like 1 January 2016. To translated them in Chinese, I use the following way with the help of Date Calculations. \usepackage{advdate,xparse} \ExplSyntaxOn ...
2
votes
0answers
45 views

Ignore special characters in \newcommand argument to generate section labels?

I am editing a rather large document and have replaced \section, \subsection etc with \newcommand macros that include \section etc but also spacing and other commands. I am trying to get it to ...
1
vote
0answers
49 views

ordinals for a new language

In this post nested \ifnum commands ordinal number naming for Georgian for biblatex. This works fine.I have defined alphabetic numbering for \renewcommand{\thesomecounter}{\anbani{somecounter}} for ...
3
votes
2answers
38 views

How to process only tokens containing a lower case letter?

The goal is to have a macro with single argument, that looks at all tokens in turn and if it sees a lower-case letter it is wrapped in \texttt{<token>}. All other tokens are passed through ...
0
votes
1answer
28 views

xparse: missing space after document command expansion [duplicate]

I'm having a problem with the below code. It's the smallest I could make the example. I'm working on a document with an index of persons, and have for this purpose created a command for each person. ...
6
votes
1answer
72 views

LaTeX newcommand with a variable number of arguments

I'm trying to create a new command in LaTeX that will let me do \begin{bmatrix}1\\2\\3\end{bmatrix} Like this: \m{1\\2\\3} I can make two functions, one for the begin and one for the end ...
2
votes
2answers
33 views

Combining \chapter command and \newcommand

I attach my MWE: \documentclass[12pt, a4paper]{book} \usepackage[utf8]{inputenc} \newcommand{\upper}[1]{\expandafter\MakeUppercase\expandafter{#1}} \begin{document} \chapter{\upper{Foo bar}} ...
1
vote
2answers
112 views

Define a new command in a `declarative way"

There are commands that look like pressing a button in MS Word(I have Windows...). For example \textbf{small bold text} compared with {\bf lengthly bold text } My question is : Is it posible to ...
0
votes
1answer
42 views

Leaving out the curly braces

I'm trying to understand how LaTeX works, but I don't understand the following: \dot X and \dot{\mathcal X} work, but \dot \mathcal X does not work. Can anybody explain why?
4
votes
2answers
52 views

how to change the style of definition of xrightarrow

we know that, the \xrightarrow can give superscript (over the arrow) and subscript (under the arrow). for example X\xrightarrow{f}Y X\xrightarrow[g]{f}Y but, I want to define a command such that ...
12
votes
1answer
133 views

Understanding etoolbox macro \deflength

The etoolbox package documentation says about \deflength: This command may be used as a drop-in replacement for \setlength. I am having trouble getting it to work with the \minof macro from the ...