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

8
votes
1answer
117 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 ...
6
votes
1answer
89 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} ...
12
votes
3answers
405 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
164 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
934 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
232 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 ...
6
votes
4answers
412 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
231 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
431 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 ...
33
votes
2answers
473 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. ...
9
votes
4answers
324 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
224 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
61 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
147 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
77 views

xparse with underscore and optional argument [closed]

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 ...
11
votes
2answers
1k 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
178 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
85 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 ...
12
votes
2answers
473 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 ...
27
votes
3answers
3k 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
335 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
180 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
873 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 ...
10
votes
3answers
267 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
109 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
210 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
71 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
82 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
157 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
106 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
180 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
104 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
139 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
185 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} ...
12
votes
1answer
3k 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
176 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 ...
6
votes
2answers
58 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
191 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
668 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
957 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 ...
5
votes
1answer
57 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 ...
3
votes
1answer
222 views

Create a custom heading in scrreprt (normal fontsize, boldface)

I finally managed to make an account here, but I have asked 2 questions before without making an account :) Ok my next question is the following: I am using the class scrreprt and the usual commands ...
2
votes
1answer
279 views

how to use tags or symbols in latex? [duplicate]

I am writing report using Latex software but I got stuck while using tags. consider a statement( for example): for any A ∈ Γ, B ⊆ A implies B ∈ Γ. The traditional (t, n) threshold secret sharing ...
4
votes
0answers
45 views

An external file with macros [duplicate]

I have many common macros in all my documents. how can I move them all to external file, and include it in each document?
8
votes
2answers
155 views

Text misplacement with certains combinations of \mathring and \overline

If I try to compile the following document \documentclass{article} \usepackage{mathtools} \DeclareMathOperator{\Op}{Op} \begin{document} \[ 1 + \mathring \Op(4) = 2 \] \[ \overline{ 1 + \mathring ...
7
votes
1answer
137 views

Is there a specific rule on how to choose package/class names?

Preamble I recently started the "custom package writing" path, which at first I found very interesting because it helped me to define standard callings of packages/commands that would have occupied ...
4
votes
1answer
106 views

Generating lists and tables of items from commands in the document

I would like to define objects all over my document and later evaluate certain components from these objects. Example: \documentclass{minimal} \newcommand{\requirement}[3]{#1, #2, #3} ...
9
votes
1answer
89 views

\centering breaks fragile command (is there a fix?)

Many on this site know (and perhaps find slightly annoying) that I will try to solve any LaTeX problem with the use of my stackengine package. My motto is like one of the overnight delivery services: ...
5
votes
1answer
64 views

Convention for packages that modify commands of other packages

I want to write a package that modify a command of another package. Let's say for example the command is \includegraphics from the graphicx package so in mynewpack.sty file I have something like that: ...
23
votes
1answer
892 views

Use of \relax after \ifnum … \fi construction

I'm reading Malcolm Clark's A Plain TeX Primer. On page 111 there's an exercise to define a macro that prints the current time. I've reproduced Clark's answer below: \newcount\minleft ...