{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.
3
votes
2answers
76 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
49 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
81 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
44 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
119 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
122 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
60 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
111 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
81 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
66 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
80 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
60 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
156 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
101 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
85 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
71 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
28 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
108 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
202 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
91 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
79 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
123 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}
...
0
votes
0answers
49 views
How to make a package using sagetex and sage-commands
I am trying to make my own package building on sagetex. It starts with
\RequirePackage{sagetex}
and I want it to execute some 'sagesilent' code as for instance
\newcommand{\loadsagefunction}{
...
10
votes
5answers
342 views
How to create a “delay expansion” environment?
I don't want to use the following
\begingroup
\edef\next{\endgroup
\noexpand\const{Xp}{\X(tp)}
\noexpand\const{Yp}{\Y(tp)}
\noexpand\const{Xf}{\X(tf)}
\noexpand\const{Yf}{\Y(tf)}
...
1
vote
1answer
41 views
import in \newcommand in my package produces an error
I have written and installed my own package gym.sty. In that package I defined
\newcommand{\loadgym}{\import{sagegym}}
since I need to execute some commands after \begin{document} for the package ...
3
votes
1answer
46 views
Vertical spacing problem with multicol package and a newcommand
The following code produces and unwanted space. Why and how can it be avoided? A redefinition of the command or macros are invited.
\documentclass[letterpaper]{article}
...
3
votes
1answer
90 views
LaTeX report wrong error line when enclosing thing within a macro
I like to write my LaTeX C++ style
1 \mydisplay
2 {
3 \BoomUndefinedMacro \\
4 x + 1 = 2
5 }
But then LaTeX, LaTeX say that the error is in line 5, instead of line 3.
This is not useful, ...
7
votes
2answers
148 views
Redefining \hrule to do nothing
Discl.: I have been using LaTeX for many years, but I am a beginner on the more advanced macro stuff.
For a specific hack of a latex document of mine, I want to override the use of \hrule within a ...
3
votes
2answers
89 views
How do I reuse a command name two or more times?
I found out how to reuse a command name.
But how can I reuse a command more times, each time using the previous definition? If I simply try something like
\newcommand{\aaa}{a}
\let\oldaaa\aaa
...
5
votes
2answers
71 views
\def issue (with NumericPlots?)
So I've decided to clean my code for the many plots.
I've basically taken out all the plot data into separate files using
\def\plotname{
x1 y1
}
Then I use \input{data.txt} to load all the ...
2
votes
1answer
39 views
Specify file name shell access via \@@input
Background:
I need to perform a conditional branch based on the first three characters of a file. I found a rather simple solution (on a Unix system, or PC with cygwin installed):
head -1 ...
0
votes
0answers
50 views
How to avoid having to use the tilde with every macro? [duplicate]
I am relatively new to LaTeX, so please bear with me.
I have just started using macros and finding them quite useful. However, I find myself having to use the tilde (~) a lot of times to get a space ...
4
votes
2answers
97 views
Write a \setcounter command to a file
I try to write a setcounter command to a file (using the newfile package) by something like the following
\addtostream{mystream}{\protect\setcounter{mycounter}{\myvariable}}
However, since the ...
3
votes
1answer
83 views
Renewcommand not working
I have a tex file compiling with no errors or warnings.
But when I add this line:
\newcommand{\mag}{randomstr}
I get this error:
LaTeX Error: Command \mag already defined. ...
4
votes
1answer
147 views
RGB colour macro: is it possible to divide by 255 in Latex?
I'm fiddling with source code display (Objective-C) and the listings package. I want to colour comments the same green that appears in XCode. I determined that it has an RGB value of 67, 133, 34. To ...


