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

12
votes
2answers
102 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
71 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
114 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
153 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 ...
8
votes
3answers
88 views

xstring command in renewcommand

I'm trying renew \texttt command with condition on ending . or ,. But after making this: \usepackage{xstring} \let\OldTexttt\texttt \renewcommand{\texttt}[1]{% \OldTexttt{\hspace{0.4em}#1}% ...
3
votes
1answer
51 views

Suppress output for a group

I have an \item style command where I need to be able to suppress output for the following text. I can do this with \nullfont, but that seems like a poor hack. Is there a declaration that will ...
6
votes
2answers
81 views

How to change the order in new commands

Being quite an amateur to LaTeX, I am sorry, I don't know how to ask my question without telling the whole story: In a large document, I made a rather simple command for citing (Classical Latin) ...
19
votes
2answers
322 views

Is it okay for a command to slurp more arguments than it is passed to?

Is it okay for a control sequence \foo to include another control sequence \slurp which slurps more arguments than \foo actually passes to it? For example, is it okay to do this: ...
3
votes
2answers
79 views

How to use a TeX macro with a CSV list to filter an external file

The code below produces the results I desire, which is a list of the lines with XXX={<value>} with a <value> which is not one of the allowed list of values: However, this solution ...
4
votes
1answer
62 views

Redefining formatting commands to add colors

I'm writing a document, and I'd like for all bold text to be red. I was wondering how I could renewcommand the textbf command so that it would be wrapped in \textcolor{red}? Thanks
6
votes
1answer
52 views

Why doesn't font family change take effect when using AtBeginEnvironment{figure} together with memoir?

I'm trying to use \AtBeginEnvironment{figure} to customize the font family and font size used in figures. However, it doesn't seem to have any effect. Here is a minimal example: ...
4
votes
2answers
82 views

Concatenate macro name \foo + bar ==> \foobar

If in a command \foo is one of my arguments, e.g. #1 how can I do a \def for \foobar, i.e., define a command with bar added to #1? Specifically I try the following \documentclass{scrbook} ...
0
votes
1answer
45 views

Problem with renewcommand?

I want to change the command \textsubscript to \tsub by writing the following line in the preamble: \renewcommand{\textsubscript}{\tsub} but, unfortunately, it doesn't work !
4
votes
1answer
77 views

Naming conventions for macro names that include the package name

Background Many packages provide commands that have the full name of the package, or an abbreviation, as part of the command name. Sometimes the package name (or abbreviation) is at the beginning of ...
4
votes
1answer
120 views

Search specific entries in database

I have written a command, which takes five arguments to interpolate between two points. Now I tried to get the two points from an csv file. \documentclass{article} \usepackage{expl3} ...
5
votes
2answers
124 views

\makeatletter explained

I am using the following code in my beamer document to make the frame title's appear in the table of contents: \documentclass{beamer} \usetheme{default} \usepackage{bookmark} \usepackage{etoolbox} ...
5
votes
1answer
66 views

using more than 2 arguments in a pgfplots style

Based on How to plot data from multiple filters using pgfplots I got a follow up one. I would like to filter not only for one value of P for each plot but for also for X values that are smaller than a ...
3
votes
1answer
52 views

How can I create a list with arguments passed to a macro?

Straight forward question: \newcommand{\optaxis}[1][]{ \ifemptyarg{#1} {\begin{axis} [xtick={0}, xmin=-1, xmax =1, xticklabels={#2}, box plot width=5mm]} {\begin{axis} [xtick={0,1}, ...
4
votes
1answer
114 views

Preprocessing Latex: What is your workflow? Your tools?

I know, for various reason, some users preprocess their latex file using Perl or sed, say. I'm considering doing this to, so I would like to seek your guidance, to smooth my entry in this area. My ...
4
votes
2answers
83 views

Updating a variable

I define a variable using \def\x{0}. How can I update this variable by adding 1? \def\x{\x+1} doesnt work (it just gets stuck in an infinite loop) Or can I define variables in some other way that ...
1
vote
1answer
63 views

What's the difference between these kinds of redefinitions?

Trying to implement an own titlepage style I am encountering a few problems. Specifically I am trying to show the authors in a different style (the show case below is not restricted to \author but ...
4
votes
3answers
255 views

How could the macro xii.tex be simplified into a better readable form

I was reading some TeX guides from where I have found this source: \let~\catcode~`76~`A13~`F1~`j00~`P2jdefA71F~`7113jdefPALLF PA''FwPA;;FPAZZFLaLPA//71F71iPAHHFLPAzzFenPASSFthP;A$$FevP ...
6
votes
2answers
70 views

How can I define a calculation of a dimension that I can reuse in a \savedanchor declaration?

In the following MWE, I declare a new shape myshape. In several instances, I plan to use a dimension that is calculated from different pgf keys (\my@width). One of these instances includes the ...
6
votes
2answers
108 views

Delaying command expansion that appears in \begin handler until \end handler executes

I have a custom environment for handling a code interface declaration that is specified as: \begin{decl}{FOO} \param{in}{bar} the bar input parameter \param{out}{baz} the baz input parameter ...
1
vote
1answer
71 views

Trick Supertabular into Multicols in new command

I'm using supertabular in multicols enviroment using this trick \let\mcnewpage=\newpage \makeatletter \renewcommand\newpage{% \if@firstcolumn \hrule width\linewidth height0pt ...
6
votes
2answers
82 views

Limit macro/newcommand scope to section

How can I limit the scope of a \newcommand to a \section? This is what I'd like to have: The command is defined only inside the \section, not globally; The command scope is that \section and cannot ...
3
votes
2answers
72 views

Creating a section template

I'm reading a lot of papers, and writing notes on them as I go. I want to make a single document containing one \section for every proceedings-year, with a \subsection for every paper. (I'm using ...
1
vote
0answers
68 views

How can I show LaTeX commands (without them being parsed)? [duplicate]

I am including LaTeX in my acknowledgements section of my thesis. I want to do something like: \item LaTeX - because I can type \text{\cite{latext}} to make a citation\cite{latex} But both ...
4
votes
1answer
61 views

Where are the biblatex macros defined?

Today I wanted to modify some of biblatex's bibliography driver macros (in my special case it was the url+urldate macro). My plan was to copy the macro from the biblatex package of my TeX distribution ...
12
votes
2answers
160 views

Expanding arguments before macro call

I've been banging my head against this for days. I have a macro which takes a macro name and its arguments. It then re-arranges the arguments a bit and then calls the passed macro with the re-arranged ...
8
votes
4answers
105 views

Stripping off non-alpha characters before calling \csname … \endcsname

I have a big text referring to 500+ scientific epynoms like e.g. "Maxwell's equations". These eponyms should go into the main index and they should also show up in footnotes - but only ...
5
votes
1answer
86 views

Label and page number in macro?

I'm writing a long document, and I've written a little macro for keeping track of various things I want to come back to - for example if I want to continue writing but I know that something I've ...
4
votes
1answer
73 views

representing literal characters in a \newcommand or \def

Consider this short LaTeX document: \documentclass[11pt]{article} \usepackage[T2A]{fontenc} \usepackage[utf8]{inputenc} \usepackage[russian]{babel} \def\name{...} \begin{document} Hello: \name ...
2
votes
1answer
81 views

How to check if token is a macro?

I am thinking about possibility to parse LaTeX document. What I really need is to track category codes of symbols. As I understand TeX expands all of macros in his mouth and tracks changes of category ...
1
vote
0answers
39 views

Get confused about the `command` option in some ConTeX \setup*

Since I switched to ConTeXt from plain TeX, I always get confused about macros in it. Now it is the command option in \setup* of ConTeXt. In ConTeXt, some macros, like \setuphead, \setuplist, have ...
4
votes
1answer
90 views

Create “bracket free” macros (like in mimeTeX)

In mimeTeX, an abundance of macros like \cd = \cdot, \fr = \frac and \sq = \sqrt are allowed. This kind of macros are easily created in own LaTeX documentens, using \newcommand. Other mimeTeX macros ...
1
vote
0answers
29 views

close appending to aliased newcommands [closed]

I have: \newcommand{\alias}[0]{POS} and use it as: ... \alias ... I want to sometimes pluralize it, output as: ...POSs... but this (obviously) doesn't work: ... \aliass ... nor does this: ...
4
votes
1answer
70 views

Writing macros on file defined at compilation time

This is a follow-up to this question. I have a LaTeX3 code that reads a file formatted as follows: <numberA> "<nameA>" <numberB> "<nameB>" <numberC> "<nameC>" ...
4
votes
1answer
109 views

Add \par only if last paragraph did not end with displayed math

Background: I have named "sections" (sections for rest of this question) which are conditionally displayed or suppressed based on parameters. To simplify the test case below, these are controlled by ...
8
votes
0answers
207 views

A flexible derivative macro with LaTeX3

In an earlier post I asked a question about writing a flexible derivative macro, and someone suggested that a LaTeX3 version might be easier to understand, so I decided to try my hand at writing one. ...
5
votes
1answer
65 views

How to make pgfplotstable read tables with macros

I want to migrate my tables to pgfplotstables. I used to have a macro for the rows of my tables, partly, because Kile used to. So currently, my tables more or less look like: oldtable: ...
2
votes
1answer
92 views

Using \item within \newcommand

I tried defining a new command \Quest as follows but the error Lonely \item--perhaps a missing list environment appears. \def\solnversion{0} %%set this to 1 to get solutions ...
4
votes
1answer
80 views

Creating a strikeout command

I am trying to create a command that works in mathmode which simulates a strikeout diagonally while leaving the math display intact. \documentclass{article} \usepackage{amsmath,amssymb} ...
6
votes
1answer
127 views

Is there a \renewtheorem equivalent of \renewcommand, using amsthm and not ntheorem?

Suppose I have a theorem that is defined a certain way, as follows. \newtheorem*{mytheorem}{Foo} And I want to redefine it another way further down in my document, as below. ...
3
votes
1answer
56 views

How can I define a new environment which limits the scope of \newtheorem commands?

I am attempting to make an environment out of the command given in one of the answers to this question: Customizing theorem name. \documentclass{article} \usepackage{amsmath} \usepackage{amsthm} ...

1 2 3 4 5 32