{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.
4
votes
1answer
31 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
124 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
60 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 ...
7
votes
4answers
145 views
Special macro definition
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
48 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}
...
3
votes
1answer
84 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 ...
9
votes
1answer
63 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
87 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
59 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
96 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
44 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
84 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 ...
3
votes
2answers
60 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}
...
6
votes
2answers
207 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] ...
21
votes
5answers
353 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 ...
8
votes
2answers
89 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 ...
2
votes
2answers
94 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
76 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
63 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 ...
3
votes
2answers
72 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
51 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
42 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
58 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 ...
3
votes
1answer
74 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
44 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.
11
votes
1answer
145 views
Is there a method just write `---` to get an em-dash, putting thinspace both before and after it?
Is there a method just write --- to get an em-dash, putting a thinspace both before and after it?
The situation about break is similar with the original ---.
6
votes
2answers
63 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
57 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
86 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
81 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}
...
2
votes
2answers
71 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 ...
7
votes
1answer
57 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
100 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
61 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
57 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
70 views
tokenizer does not work
\documentclass[a4paper]{article}
\usepackage{comment}
\usepackage[trim]{tokenizer}
\usepackage{ifthen}
\usepackage{xargs}
\usepackage{xkeyval}
\usepackage{xfor}
\begin{document}
\makeatletter
...
0
votes
0answers
38 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}
...
4
votes
1answer
52 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
58 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
61 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
96 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
101 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
71 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}
...
4
votes
3answers
78 views
TikZ - bad positioning of images drawn by macro
Probably a lame question about how positioning in TikZ works.
I'm trying to draw some electrical stuff (starting on the level of single gates) and because many of them repeat over and over, I want to ...
3
votes
1answer
60 views
I want \newcommand to replace something in a document by something else
I want to define \newcommand{\B} in 2 different ways and switch between them in the simplest way – just using a comment mark, %. Let's look at the example:
\documentclass[a4paper,9pt]{article}
...
5
votes
2answers
68 views
Floating Point multiplication in custom commands
I'd like to create a custom command which creates an underscore of a given length. However, this length should be the argument of the command multiplied be a floating point constant.
How can I ...
3
votes
2answers
55 views
Reading arguments in a command?
I now know that if I want to get for example the 3rd argument passed to a command, I have use #3. My question is if this argument is an array how can I read elements of array without a for loop?
For ...
0
votes
0answers
38 views
TeX, LaTeX capabilities in counting occurrences in text of chars defined in a given list
I am asking this question in part because I am not completely aware of TeX, LaTeX capabilities. Imagine that I want to count the number occurrences of charecters defined in a certain list. The usage ...
7
votes
1answer
113 views
Wrapper for siunitx' \SI macro to automatically split number and unit
Problem
I use the siunitx-package to typeset numbers and units with correct spacing etc. There is a command
\SI{<number>}{<unit>}
for that. However, it would be much easier to write ...
4
votes
2answers
151 views
Graphical vertical rule in tikz
I would like to make design (class), where I would like to have special type of paragraph that will have { character on left and will have height exactly same as height of whole paragraph. Also, I ...

