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

2
votes
1answer
3k views

Compilation fails with “! Missing \endcsname inserted.”

Hi I've got a strange problem. I've defined a new command to print Linux commands line in the document: \documentclass[12pt,a4paper]{article} \usepackage{listings} \newcommand{\shellcmd}[1] { ...
3
votes
1answer
208 views

How to use pgfkeys' /.style args handler without knowing the exact form of the input?

I would like to be able to create a command (using pgfkeys) that can take inputs that are of a limited set of forms, and for which certain pieces will come from a limited set of values. More ...
5
votes
1answer
614 views

How to run LaTeX and lilypond-book in one command?

I was wondering if there was any command which would let me create a PDF from a LyTeX source in one step. Currently, I am first executing lilypond-book: lilypond-book --latex-program=pdflatex --pdf ...
4
votes
1answer
2k views

Command \* already defined … see p.192 of the manual

My code had: \newtheorem*{theI}{Thesis I} And it gives me the error: Command \* already defined. Or name \end... illegal, see p.192 of the manual. 1.16 \newtheorem*{theI}{ ...
4
votes
1answer
66 views

Expanding a macro into a long list for use with pgfplotstable

Failing again to get macros to work. I have the following M(n)WE \documentclass[10pt]{article} \usepackage{pgfplotstable} \begin{document} \xdef\mydef{ \foreach \a/\b in ...
8
votes
2answers
398 views

Package xparse \SplitList last token

I need to create a macro to render lists with a variable number of arguments (1+), e.g. \mylist{1,2,3} should expand to $\tilde{1}$--$\tilde{2}$--$\tilde{3}$. I'm trying to use xparse and \SplitList, ...
7
votes
1answer
215 views

Writing \\ to a File

I have a local class that a number of people use. One of the new things I want it to do is write out various user-defined data to a file, so that a follow-up LaTeX document can do something ...
3
votes
3answers
81 views

Environment with coordinate-like arguments

I would like to define an environment which takes coordinate like arguments (1,2). I think about two different calling schemes: \begin{myenv}(mandatory coordinate)[optional](optional coordinate) ...
4
votes
1answer
84 views

Remove macro from list like LOF

When defining a new section or when adding a caption to a figure or a table, the content of that command is normally duplicated. One version is put directly into the text, i.e. as a heading or below a ...
11
votes
3answers
366 views

Understanding etoolbox \ifdefempty and \ifdefvoid

I am trying to understand the etoolbox \ifdefempty and \ifdefvoid macros. The documentation says that \ifdefempty Expands to true if the control sequence is defined and is a parameterless macro ...
5
votes
2answers
122 views

How can I use the same parameter for \Tree and \exi

The qtree package permits drawing syntactic trees with a syntax like this: \ex. \Tree [.S [.NP This ] [.VP [.V is ] [.NP an example ]]] The linguex package typesets bracketed expressions with a ...
8
votes
4answers
229 views

Special macro definition (2opt, 1mand)

How can you define a macro \cmd in TeX primitives using two optional arguments (and a mandatory one) that fulfills the property that calling \cmd[opt]{mand} is equivalent to \cmd[][opt]{mand}. Yet, I ...
4
votes
1answer
97 views

Dividing Scrolling text

Based on the video available here : http://www.youtube.com/watch?v=vkBCeOBbAmM I try to understand what the following code does \def\text{\setbox\galley=\vbox\bgroup \hsize= 5cm \hrule} ...
7
votes
1answer
1k views

Where does TeXstudio store the .cwl files for hyperref and xspace?

TeXstudio uses .cwl files for storing information about which macros are defined by which packages, one file per package. This information is used for autocompletion suggestions and highlighting of ...
10
votes
1answer
124 views

Expandable, very specific keyval processing

I am having a hard time trying to come up with an fully expandable keyval parsing macro which deals only with specific keys/values. I wouldn't even attempt this in full generality, that's way beyond ...
3
votes
1answer
391 views

LaTeX XY positioning

I have not been using latex in a while and I would like to try to implement the tips & tricks given in this video during the TUG conference by Jean Luc Doumont : ...
4
votes
1answer
419 views

LaTeX not recognizing \end found in a \newcommand

I'm trying to both start and end a table with \newcommand. I'd like to switch to using \EndTableSetupFourColumns (as it removes several warnings and is easier to understand for other readers) but for ...
6
votes
2answers
320 views

Custom verbatim that sets all spaces (“ ”) as visible spaces (“␣”) that can line-break

It makes sense to typeset code in a monospaced font. Sometimes such code needs to be embedded in a paragraph context, and then it will be useful to allow it to linebreak. In order to visualize spaces ...
4
votes
1answer
48 views

Inserting noncrossing partions

I am trying to create non crossing partions in latex. That is to connect numbers with lines drawn below them. An example would be 1 2 3 4 5 │└┘││ └───┘ But the lines should be directly ...
3
votes
1answer
92 views

Help me fix this code

I wanted to try to learn how to define a lot of macros at one go. After I asked this on the chat room, I received some code from the awesome egreg to play with. Here is a link to working code. There ...
4
votes
2answers
305 views

Increasing the length between rows in a table

I have defined a new command to increase the length between rows in a table: \newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}} For example \documentclass[a4paper, 11pt]{article} ...
7
votes
2answers
260 views

What does \s! do?

1st example: \starttypescript [\s!serif] [paratype] \definefontsynonym [ParatypeSerif-Regular] [\s!name:PTSerif-Regular] [\s!features=\s!default] \definefontsynonym [ParatypeSerif-Italic] ...
22
votes
5answers
507 views

Easier way to make permutation diagrams?

I prefer using figures created inside TeX, but I only know very labor-intensive methods. The following creates a permutation diagram for (6,3,2,4,1,5) with some colors and additional symbols. I'm ...
9
votes
2answers
182 views

Put all package options into one command

The title might not be perfect, but what I want to achieve is: Inside my own package mypackage.sty, I would like to have a command, say \allpackageoptions, which should have stored the entire package ...
3
votes
2answers
163 views

Kind of spurious space

I'm trying to write a \spaced macro: it takes a string as parameter, decompose that string and then recompose it spreading avery token from the others according to a given \spreadratio. Here are the ...
2
votes
1answer
201 views

Cutting string with formula or cite

I am trying to define a macro that would take a string and paint its ending, for example: \def\paintString#1{% \saveexploremode% \exploregroups% \textcolor{white}{\StrGobbleRight{#1}{5}}% ...
1
vote
1answer
227 views

Pass key option inside a macro to a TikZ drawing command

I define a command with one optional key parameter. This command makes some calculations and them draws a tikzpicture. How can made my command to accept all the keys that a \draw command accept and ...
6
votes
2answers
1k views

Declaring a math operator with cursor placement, e.g. expected value

I'd like to declare a new math operator \ev for representing the expected value, in the form: E<.> so that it looks like the following but with an argument ...
2
votes
2answers
288 views

Renewdefine section with additional argument

My goal is to redefine the command \section with a new argument for labeling: \section[Title in TOC]{Title}{label} \documentclass{article} \let\oldsection\section ...
5
votes
1answer
66 views

How to redefine \str_if_eq:xxTF for backward compatibility

I just updated all the packages for TeXLive 2012 today and it appears that \str_if_eq:xxTF has been deprecated. How do I define a macro so that I can use the latest TeX Live but still be able to run ...
5
votes
2answers
299 views

Double subscript error with \newcommand?

Disclaimer: I know of Defining a newcommand with sub- or superscript and avoiding "double subscript" error but this only gives a work-around, but no explanation to my question. Here's a ...
8
votes
1answer
268 views

auto-capitalise the output of a newcommand

How can I create a newcommand that automictically capitalises the first letter, when the command is used after a full stop (or question mark, exclamation mark, etc.)? \newcommand{\tinycommand}{tiny ...
0
votes
1answer
149 views

Override quotation style [duplicate]

Is it possible to override the default quotation marks of ``notation''? As a czech user, I have to use \uv{} to have czech styled quotations, which doesn't write so well.
6
votes
2answers
175 views

babel + xdef compile error

The following code throws the error Incomplete \iffalse; all text was ignored after line 7 when I enable the babel package. \documentclass[a4paper,12pt]{book} \usepackage[latin1]{inputenc} ...
3
votes
1answer
240 views

What does \nop mean and how to use it

I wonder what does the \nop mean, and how does it work? I Googled it but couldn't find a good answer, for example, I found something like: \newcommand{\nop}[1]{} in my .tex file, so what does it ...
7
votes
2answers
193 views

Negating \ifeof

Trying to typeset lines from a file: \openin0=MyFile \loop \read0to\linein \linein \ifeof0 % Fails here \repeat Clearly, I want to test for not \ifeof, but I don't see a boolean ...
4
votes
1answer
138 views

How to change an environment into newcommand?

Suppose that I want to create a new command named step, which functionally add Step 1., Step 2., and so on in the proof. This can be done by: \newcounter{stepnum} ...
3
votes
2answers
173 views

Ignore some self-defined command during compilation?

In a .tex file, there is some self defined command \newcommand{\mycomment}[1]{\textcolor{red}{#1}} ... \mycomment{blah blah} ... I hope to be able to skip the command during compilation in my final ...
8
votes
1answer
112 views

What's the differences between the kernel commands \trivlist and \list?

LaTeX defines the two environments \trivlist and \list. Both can be used creating own environments. What exactly is the differences between \trivlist and \list?
6
votes
2answers
165 views

Does \let use pointers?

Does \let really create a new control sequence, or does it just assign a pointer to an already defined control sequence? Knuth says that: let\cs=<token> gives \cs the token's current ...
4
votes
1answer
112 views

Exposing a new command for each element of a list

I have a macro lVars, defined using foreach from the pgffor package (part of PGF) as: \newcommand{\lVars}[1]{\foreach \x [count=\ii] in {#1}{ \ifnum\ii=1{} \else {,} \fi \lVar[\x]} } The intended ...
5
votes
2answers
125 views

Whole word as a macro argument when macro called without braces

I have a macro: \newcommand{\sEmph}[1]{\textbf{\textcolor{NavyBlue}{#1}}} Then I can do: Some text is in \sEmph{blue}, and some in black. with this result: But if I omit the braces only the ...
0
votes
0answers
73 views

tokenizer does not work [duplicate]

\documentclass[a4paper]{article} \usepackage{comment} \usepackage[trim]{tokenizer} \usepackage{ifthen} \usepackage{xargs} \usepackage{xkeyval} \usepackage{xfor} \begin{document} \makeatletter ...
2
votes
1answer
83 views

\end{tabu} in \newcommand

I want to put \end{tabu} within a \newcommand \documentclass{article} \usepackage{tabu} \newcommand {\tableBegin}[1] { \begin{tabu}[#1] % some other stuff } \newcommand {\tableEnd} ...
5
votes
1answer
154 views

Count chars with xstring

I have the following code, which was provided by the xstring author Christian Tellechea, thank you very much. The idea is to count the number of character inside a structure that do belong to a ...
3
votes
2answers
107 views

How to append commands to a macro without expanding them

I'm working on building an expenses package. The intention is to be able to write \expense{someone}{something}{something a bit longer}{10}{GBP} \expense{someone else }{something else}{something a bit ...
1
vote
1answer
264 views

\newcommand with PythonTeX PyCode

Environments are MiKTeX 2.9, XeLaTeX, PythonTeX 0.11 beta, and Python 3.3. I am pretty new to LaTeX and Python/PythonTeX and am struggling with the following piece of code. %!TEX TS-program = xelatex ...
4
votes
1answer
383 views

How to prevent a page break between paragraphs

I would like to typeset something like a "quote plus attribution", e.g. at the beginning of a book chapter. It should look like this: CHAPTER TITLE This is an introductory quote. ...
12
votes
2answers
193 views

Align*, & and \futurelet

can somebody explain futurelet within align-environments? Example: The command \A should give an "A" if the next char is a {, a "B" if it is & and "C" in any other case. ...
4
votes
2answers
154 views

\lowercase inside \url

Why is this snippet: \newcommand{\Subject}{Skeleton} \url{http://www.cheatsheet.jim.pm?subject=\lowercase{\Subject{}}} rendered to this? http://www.cheatsheet.jim.pm?subject=\lowercase{Skeleton} ...