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

3
votes
2answers
66 views

Determining spacing by a number that is a multiple of a counter

I have \hspace and I have a stepcounter xyz \documentclass[12pt]{article} \usepackage[top = 1in, bottom = 1in, left = 1in, right = 1in]{geometry} \usepackage[T1]{fontenc} ...
5
votes
1answer
74 views

Write a macro with \command, {, and } in argument

I understand that TeX macro arguments can be parsed using proper delimiters. And as the classic example goes in The TeXbook, Along the same line, I tried to define a macro (for some special ...
3
votes
1answer
97 views

Redefine \item command to not typeset some items

Suppose I want to have an enumerate environment, in which I don't want to typeset certain items. I can obtain this in LateX using (let's ignore the problem that the numbers are wrong, this is easy to ...
6
votes
1answer
155 views

evaluate a string like `sin(x)+3` with `x` given

I defined a macro that gets as input a string like sin(x)+3, a starting x and an ending x, which is plotted using \addplot from PGFplots. Now I want to evaluate this function for x equal to the ...
6
votes
2answers
102 views

Redefine 'includegraphics' to add space

I am trying to redefine the command includegraphics to add vertical space below and after my image (I am not using the figure environment since I need to place my images quite carefully.) I was ...
9
votes
2answers
183 views

Still having difficulty with use of `\expandafter`

Firstly, my apologies for any previous confusion, I've separated out various questions onto distinct pages. This problem came up in the context of trying to split a decimal number. Good solutions to ...
8
votes
1answer
97 views

Implement functionality equivalent to many thousand \savebox

I have a large (approx 600 pages) index of files, and for each file entry significant computation is required so that additional links can be added. The computation of these links takes quite a bit ...
5
votes
1answer
58 views

Behavior of xparse and “token”-type argument

Please consider the following example: \documentclass{minimal} \usepackage{xparse} \NewDocumentCommand{\f}{tx}{\IfBooleanTF{#1}{true}{false}} \begin{document} \f{x} \f[x] \f x \end{document} ...
9
votes
3answers
184 views

Read strings from file that contains the special character #

I need to read some values from data files as given in the sample code. The problem arises when the files contain # character. Then I get " ! Illegal parameter number in definition of \@xs@call " ...
7
votes
1answer
139 views

Macros with binary trees as arguments

I would like to have some macros which have binary trees as arguments. For the purpose of these macros, a binary tree is either root or it is {branch1}{branch2} for two binary trees branch1 and ...
1
vote
1answer
219 views

Math Symbols Palette?

I'm using TeXworks version 0.4.3 r857 (MiKTeX 2.9) in Windows 7. Usually I use TeXShop on the Mac, but my Mac G5 is in need of repair. So now on the Windows side I'm wondering if there is an ...
7
votes
3answers
168 views

\newcommand and name of command

I would like to automatically generate commands like \newcommand{\Air}{\gls{air}} \newcommand{\Earth}{\gls{earth}} ... to use with glossaries package, without using \newcommand for every entry of ...
4
votes
4answers
214 views

How to repeat text

I get interesting errors with the following macro. Mostly it works, but I get extra spaces after \noindent (but not after \newline). I tried using \loop or \whiledo (from ifthen) but get stack ...
10
votes
1answer
214 views

Is \10 allowed as a control-sequence name?

At the beginning of Chapter 3: Controlling TeX of his TeXbook, Knuth explains that control sequences come in two flavours: control words and control symbols. Control words The first kind, like ...
7
votes
1answer
301 views

Separating a decimal number into whole and fractional parts with only the digits using pgfmath

Note: Firstly my apologies for making this confusing to start with. I have finally clarified matters I hope. This particular question is asking for macros that will split pgfmath results. The ones ...
0
votes
0answers
33 views

Putting itemize environment in a tabular environment [duplicate]

I have a macro that makes an itemize environment. When I tried to use the macro in a tabular environment, I have this error message. ERROR: LaTeX Error: Something's wrong--perhaps a missing \item. ...
30
votes
2answers
354 views

What are the standards of TeX/LaTeX coding in order to obtain robust packages?

I have posted several questions ultimately involving various aspects of robustness, that have arisen in the context of other questions in risk of clouding the main point of the question in each case. ...
8
votes
4answers
167 views

How can I reference the current (sub)section number?

I want to create a macro that dynamically returns the current chapter, section, subsection (etc.) I'm in. I've created a macro called \getCurrentSectionNumber that does this, but it lacks the ability ...
5
votes
1answer
109 views

How can I define a macro with literal square brackets in the body?

The following macro works correctly for enclosing an expression in parenthesis. \def\group#1{\left ( #1 \right )} I want to write the equivalent macro for enclosing an expression in square ...
1
vote
1answer
56 views

Add custom caption to LOT file

In my publishing company we have our own template with custom \tcaption command which make caption above the table with company's standards (and I don't use table environment). However this command ...
4
votes
1answer
88 views

\AtBeginSection in other document classes like article or book

I understand that there is \AtBeginSection in beamer class which allows us to execute a set of commands at the start of each section. As we find in beamer guide, \AtBeginSection[⟨special star ...
4
votes
0answers
55 views

xparse with underscore and optional argument

I need a macro which handles its input as follows: \foo A > #2 = A \foo{A} > #2 = A \foo(B) > #3 = A (round brackets) \foo_m A > #1 = m, #2 = A \foo_m{A} > #1 = m, #2 = A \foo_m(B) > #1 = m, #3 = B ...
10
votes
2answers
180 views

Is \baselineskip automatically defined?

Is is automatically defined by LaTeX? What does it depend of? I was going through the Wikibook section regarding lenghts, and I just realized also that \bigskip and others are not dependent on the ...
11
votes
3answers
109 views

Mirror tilde accent

Does anybody know if there is a "mirror" tilde accent command in any package? That is, the "wiggling" of the tilde accent going in the other direction. Something like defining this \backtilde ...
2
votes
1answer
75 views

TeX and Hyper text links

I am a TeX (not LaTeX) user (and a member of UK TeX user group) of many years and produce macros for maths and complex tables. I include some hyper text links within a document using the Y&Y ...
10
votes
2answers
164 views

How is \unexpanded defined?

I was wondering how \etoolbox's \expandonce does what it does. So I looked up how it was defined and found \unexpanded\expandafter{#1} But no matter where I look, I cannot find a definition for ...
25
votes
3answers
761 views

Defining a new function with argument in LaTeX environment

I want to define a function in a LaTeX document. More precisely, I want to define a function, say \ang{x}, where x is any input, such that the output is \rangle x \langle. Is there a way to go about ...
9
votes
2answers
229 views

How can I encode the current document as a QR code with pst-barcode?

\documentclass{article} \usepackage{pst-barcode} \begin{document} \begin{pspicture} \psbarcode{\input{\jobname.tex}}{}{qrcode} \end{pspicture} \end{document} I tried placing \expandafters before ...
6
votes
1answer
144 views

Problems with passing values through nested levels

Inspired by a comment to another question, I'm trying to generalise some code to draw coloured in rectangles upon the graph of a function. The routine \findmax, given an x-value and a function, ...
4
votes
2answers
264 views

Left-align the date for all cvitems

All contents (mostly dates) of the first argument of \cvitem should left-align in Austria - as explained to me in the career center. I want to redefine the command \cvitem (like in Can I redefine a ...
0
votes
0answers
33 views

Employing options of the figure or table environment via \newcommand

I am writing a large document in which I would like to employ the options of figure environments via \newcommand{\figposa}{H} \newcommand{\figposb}{T} \newcommand{\figposc}{B} ...
10
votes
3answers
142 views

how to select a character (or word) from a list

Is there a way, with the following restrictions: No external pacakges (i.e., no substr) no conditionals (\ifnum, \ifdefined, etc) to select a character from a string? i.e. \CharAt{2}{ABC} ...
0
votes
2answers
50 views

Environment inside a command

My code \documentclass[a4paper,12pt,twoside]{article} \usepackage[english]{babel} \usepackage{amssymb} \usepackage{amsmath} \newcommand{\QUE}[1]{% {\bf Question\# 1 }: #1 }%end QUE \raggedbottom ...
14
votes
1answer
173 views

What exactly is a command in Latex?

In other programming languages I have come across a command is a verb; it is something for the computer to do. The things that commands act upon are called variables and these come in various types. ...
1
vote
0answers
67 views

Does the verb “esquisser” mean anything in Latex terminology? [closed]

Latex doesn't want me to write "esquisser". Does that mean something in Latex terminology and am I creating a command by using this word? How can I use it without creating any command?
3
votes
1answer
54 views

\newcommand for a specific chapter

I write a document with LyX, to which I add PSTricks pictures in ERT sections. I defined a \newcommand in a certain ERT section, and it was available during this ERT section, but not available in the ...
10
votes
3answers
118 views

Looping Through a Nested List

I have a hunk of data like so: { { {AA},{AB}, ... {AZ} }, { {BA}, {BB}, ... {BZ} }, ... ... { {ZA}, {ZB}, ... {ZZ} } } defined in a macro called \clebschdata. Each term XX is a list of eleven ...
5
votes
1answer
72 views

Command to make new command

I have several books with toggles/ifs for each of them (I have toggles and ifs because I had several problems with some other packages..) I defined the toggles in my style-File like this: ...
11
votes
2answers
152 views

Trouble Defining a LaTeX Command

I am trying to define a table of direct sums of {\chi_i}in LaTeX, meaning that the entries will be things of the form: 5 \chi_2 \bigoplus \chi_4 \bigoplus 2 \chi_7 for given data like ...
5
votes
2answers
83 views

A command which produces index if optional argument is not empty

I would like to define a command which creates an index with a certain name, when i pass the name, and doesn't create any index if there is no name passed. My first idea was to write it like that: ...
5
votes
1answer
120 views

How to make functions

I’m not entirely sure here what terminology I should exactly be using, but let me illustrate a use case. ... \matr{1 & 2 \\ 3 & 4} ... to replace this: ... $\left[\begin{matrix} 1 & 2 ...
10
votes
4answers
120 views

How to numprint result of command?

Faulty code: \documentclass{article} \usepackage{fp} \usepackage{numprint} \newcommand{\ratio}{% \FPdiv\result{\x}{\y}% \FPround\result\result{2}% \result% } \begin{document} \FPset\x{2} ...
8
votes
1answer
235 views

How to make \hl (highlighting) to automatically place incompatible commands in \mbox?

The soul package provides a useful command \hl for highlighting text. However, \cite, \ref, and some other commands (maybe equations too) must be placed within an \mbox in order for \hl to work ...
5
votes
1answer
118 views

Capitalization of datetime format

In languages like dutch, the first letter of the names of days and months are not capitalized unless they occur as the first character of a sentence. So I added the following code in the preamble of ...
0
votes
0answers
35 views

Retrieve current subsection and subsubsection name without label [duplicate]

How do I retrieve the current subsection and subsubsection and paragarph name without using \label. The reason is that then I would have to \label everything and I want a more automated solution. ...
6
votes
2answers
50 views

How to make a family of related optional-arg macros reliable

I have some working, but unreliable \def magic I use to reduce boilerplate regarding mathematical indices. (This is in LaTeX, but I couldn't think of a way to do it using newcommand). \makeatletter ...
4
votes
1answer
104 views

tikz def node name (or reference) for nodes create using the def

I have the following definition in order to create a node with cylinder shape \def\dnc[#1,#2,#3,#4]#5{ \node[draw, cylinder, alias=cyl, shape border rotate=90, aspect=1.6, % minimum height=25, ...
9
votes
6answers
498 views

Compiling a document to input more than 100 image files

What I want to achieve is to compile a document of pictures in .jpg format into a pdf file. The problem is that I would not want to input all the files one by one. The files follow a pattern in there ...
2
votes
1answer
317 views

passing a variable from R to Tex in knitr

I am sure this has been asked multiple times since it seems to be a common issue. I looked around but all I could find was the \Sexpr for sweave which does what I want. I am using knitr and I can't ...
4
votes
1answer
53 views

Syntax for macro arguments not behaving as expected

I'm trying to build some macros for parsing arguments of other macros in which I'm smuggling in hidden arguments. The following code works perfectly: \documentclass{article} \makeatletter ...