Tagged Questions
7
votes
2answers
155 views
Stupid error caused by doing stupid things
When I was writing my thesis I wrote the following two commands which I found useful (and still do). They are both ways of defining other commands.
\usepackage{ifthen}
\makeatletter
\def\optional ...
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 ...
3
votes
1answer
50 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 ...
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
...
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 ...
14
votes
3answers
184 views
Parsing strings containing diacritical marks (macros?)
I apologize that this question may seem very much like several other recent ones I have asked (Parsing leading hardspaces, Parsing a \$ as part of an improved \getargs command). They are all related ...
5
votes
2answers
97 views
Variadic arguments macro
I am trying to make macro with variadic arguments, iterating over them.
The final result is supposed to be:
\foreach[x]((var = \x )){foo}{bar}{baz}\null
evals to
var = foo var = bar var = baz
My ...
6
votes
3answers
173 views
Why are some characters not allowed in command sequences
From my understanding a control sequence is ended by any non-alphabetic character such that \mycsA is one token, but \mycs1 is two tokens. This means things like starred commands \mycs* are actually ...
7
votes
2answers
105 views
Is there a way of defining a command \nullifyifmoved{arg} that will normally act like its argument but act like a no-op if the macro is “moved”?
I'm interested in a macro \nullifyifmoved that takes one argument arg and acts like arg in normal contexts, except it acts like a no-op wherever it is written to a file. Some background:
Martin ...
5
votes
3answers
98 views
Metacommand for commands that dynamically select a parameter?
Original question
I would like to create a metacommand for creating new projection commands. Specifically, \newproj{\cmd}{<n>}{<m>} should create \cmd as a new command of <n> ...
4
votes
3answers
163 views
How are space tokens and empty lines processed by long commands (as their potential arguments)?
How are spaces and empty lines processed by long commands (i.e., those that do not accept paragraph breaks inside)? Are there different space tokens aside from " " and an empty line? It appears that ...
19
votes
3answers
243 views
If I redefine a command that has a starred variant, will that always disable the starred variant?
If I redefine a command that has a starred variant, will this always effectively disable the starred variant, as a side effect of redefining the unstarred variant?
A related question: Do starred ...
8
votes
1answer
121 views
Which commands exist to define new commands?
Which commands are there that one can use to define new commands in (La)TeX?
There are: \let, \def, \[re]newcommand[*], \DeclareRobustCommand[*], and ...?
(And I've seen things like ...
11
votes
2answers
106 views
Is there any reason to define a zero-argument macro using a starred defining command?
Is there any reason to define a 0-argument (read: zero-argument) macro with a starred command (\newcommand* instead of \newcommand or \DeclareRobustCommand* instead of \DeclareRobustCommand)? After ...
15
votes
3answers
263 views
When is it better to use \par than \endgraf?
Just yesterday I had to patch a package file (changing the description to indicate that the file had changed) to replace some \par to \endgraf because the code had bad interactions with non-\long ...
10
votes
2answers
177 views
What does \relax do? [duplicate]
Possible Duplicate:
How can I speed up LaTeX compilation?
What is the difference between \relax and {}?
The title suggest the question. On and off, I see macros here in TeX.SE and I see ...
8
votes
3answers
115 views
Questions on macro writing in TeX to modify an existing style file: fancybox.sty
I've decided that I must become more adept at TeX if I'm to become proficient with LaTeX. While this is probably obvious to most readers who pass by, my ability to muddle through has hidden this small ...
20
votes
3answers
310 views
@tempdima, reserved@a, @tempcnta, what else?
I'm aware that some "temporary" LaTeX dimensions etc. exist. I would, however, like to know all of them.
I know \reserved@a (macro), \@tempdima (dimension) and \@tempcnta (counter).
12
votes
1answer
117 views
How to read a stream of tokens up to one of two different delimiters
The core question
How can I process text delimited by one of two terminators? For instance, if I want to process text up to the next \A, I can just write
\def\CmdA#1\A{...}
But suppose that \A ...
4
votes
0answers
74 views
How to search for the commands in TeX [duplicate]
Possible Duplicate:
Where do I find out how a command/environment is defined?
Macro find tool
When I am reading the other's LaTeX codes, I always find new commands I have never read ...
14
votes
2answers
131 views
Use TeX macros to store multiple data
I'm trying to use TeX macros to store multiple data such as website url/name. Here is an example :
\documentclass{article}
\def\Google{{http://www.google.com}{Google Search}}
\makeatletter
...
42
votes
3answers
1k views
What is the difference between \relax and {}?
As I understand it, the point of \relax is to stop a macro from swallowing up subsequent material (such as whitespace). But {} (\bgroup\egroup) serves the same function. Why do we need both?
7
votes
1answer
268 views
Why does \@gobble take one argument
I understand what \@gobble, \@gobbletwo etc. do, but I don't understand why \@gobble allows for an argument.
I believe that the definition of the macro is \long\def\@gobble#1{}. Why is this argument ...
5
votes
1answer
111 views
Problem with xargs package
I am trying to do what I though was fairly simple - use an xargs defined macro in a CS. MWE:
\documentclass{article}
\usepackage{xargs}
\usepackage{etoolbox}
\makeatletter
\def\abx@foo@baz@bar{test}
...
8
votes
2answers
189 views
What is wrong with this TeX macro
Still soldiering on with trying to learn these macros. Can someone tell me why this isn't working?
The macro \mycline{n-n} is supposed to expand to \cmidrule{1-1} ... \cmidrule{n-n}, but in my code ...
6
votes
1answer
198 views
Storing unexpanded macro definitions (including #1, #2, …) for later use (now includes full usecase)
Preliminary Info
I'm working on a new LaTeX package to make scoping more flexible. To do this I'll be capturing and reintroducing user defined commands behind the scenes.
(For a comprehensive ...
5
votes
2answers
346 views
Most useful LaTex -macros? Help me to understand a statement with `\[p][s][frac|mat]`
I want to understand the below, source here. I am studying material related to real-time-Texing like here.
As for fractions and matrices, I prefer using LaTeX macros instead of snippets. The most ...
5
votes
1answer
86 views
Macro which creates another macro with custom name
I want to create a macro \foo which creates another macro which a custom name set just before the execution of \foo via a macro \defcommand{myCustomName} and saves/adds something to it just as the ...
6
votes
1answer
103 views
Arbitrary text parsing from a separate file
I'm still very new to the world of TeX, so please bear with me if this question is unclear or has been asked before. I'm starting to figure my way through TeX and the millions of plugins and ...
5
votes
1answer
85 views
Gobble every occurrence of \mypath../
Is there a neat way to remove all instances of the text \mypath../ from the input, using TeX's text processing capabilities? The ifthen approach below works, but seems to be a bit heavyweight. Also, ...
21
votes
7answers
341 views
Fully robust way to access the first item in a token list (expandably)
Given a token list such as \a\b\c or {ab}c, I define the first item to be what \@gobble would get as its argument (recall the definition \long\def\@gobble#1{}). It is not hard to devise a macro which ...
21
votes
2answers
273 views
Lifespan lines in TeX
I'm writing a document (written in plainTeX) about the lives of important mathematicians and physicists in human history.
Now I have a problem I'd like to tackle. I need to be able to visualize their ...
5
votes
2answers
586 views
Passing argument to \ifnum
\ifnum works fine it it's got two straight numbers. However, when calculation is involved, I get bunch of ! Missing = inserted for \ifnum. errors. Is there any way to solve that problem?
...
35
votes
3answers
774 views
Advantages and disadvantages of fully expandable macros
As I currently understand them, fully-expandable macros are analogous to pure/effect-free functions in functional programming. Correspondingly, things that are not expandable, such as \def, are ...
4
votes
1answer
267 views
Faking small caps in XeLaTeX
In the post Fake small caps with XeTeX/fontspec? I have found the following definitions to fake small caps
\def\mycommand{\bgroup\obeyspaces\mycommandaux}
\def\mycommandaux#1{\mycommandauxii ...
22
votes
3answers
519 views
How to know whether or not we need \expandafter?
The following is quoted from Peter Grill's answer on question LaTeX dynamic macro definition.
The \expandafter is requried as the \newcommand needs to be dealt
with after the \csname.
As a ...
10
votes
3answers
220 views
Expandable 'character scanning' command that preserves spaces
David Carlisle recently offered a clean and rather elegant TeX solution to a question about expandable 'character scanning' commands. Unfortunately, David's solution does not preserve spaces in the ...
42
votes
0answers
1k views
A LaTeX log analyzer application (visualizing TeX expansion)
Consider the following MWE, test.tex:
\documentclass[12pt]{article}
\begin{document}
\tracingassigns=1
\tracingmacros=1
\def\aaa{something}
\def\bbb{else \aaa, else}
\edef\ccc{third \bbb, level}
...
5
votes
1answer
243 views
A \typeout (or expandable command) that can expand once - or with variable levels of expansion?
Consider the following MWE:
\documentclass[12pt]{article}
\begin{document}
\def\aaa{something}
\typeout{=1==\aaa==}
\typeout{=1==\meaning\aaa==}
\typeout{}
\def\bbb{else \aaa, else}
...
2
votes
1answer
117 views
Use the catchfile package to preprocess an input file character by character?
Is it possible to read a file using the \CatchFileDef or \CatchFileEdef commands from the catchfile package and then output its exact copy to another file? What about input and output encoding? Do ...
2
votes
2answers
173 views
An expandable 'character scanning' command?
Please consider the following MWE, for a "character scanning" command "\looper" which utilizes \@tfor:
\documentclass{minimal}
\usepackage{trace}
\makeatletter
\newcommand\looper[1]{%
% ...
3
votes
1answer
128 views
Showing expanded `\let` command with `\typeout`
I have already seen the related page macros - What is the difference between \let and \edef?, but I'm afraid it still doesn't expain to me the following MWE:
\documentclass{minimal}
...
5
votes
2answers
221 views
On unprotecting (expanding) \protected macros (or, “the space after command name”)
I quite often come into a situation, where I need to obtain some text produced by a package macro as a string, like in say:
Expanding (edef) a lipsum command?
How do I "unprotect" an ...
0
votes
2answers
180 views
TeX Programming questions (and stuff about parcolumns)
I'm trying to modify the inner workings of parcolumns. I'm starting to understand the TeX macro "programming" language a bit but I have some issues.
In paracolumns there are three issues I want to ...
1
vote
1answer
154 views
Unexpected scoping issue using \XeTeXinterchartoks
Minimal example (compile with xetex):
\XeTeXinterchartokenstate = 1
\newXeTeXintercharclass \classa
\XeTeXcharclass `\a \classa
\XeTeXinterchartoks 255 \classa = {\begingroup}
\XeTeXinterchartoks ...
1
vote
0answers
67 views
How to print the newline character “\\” from a macro so that it is recognized as newline in tabular [duplicate]
Possible Duplicate:
How to programmatically make tabular rows using \\whiledo ?
I have a problem that may have an interesting answer. I am writing a macro whose output I would like to be a ...
8
votes
2answers
134 views
Execute non-expandable code inside a tabular environment
As there is no Expandable version of \InputIfFileExists or \IfFileExists, the question arises whether it is possible to execute non-expandable code in a tabular environment after all:
File main.tex:
...
7
votes
2answers
258 views
Force the expansion of a macro parameter without \edef or \xdef
Two days I am looking for a solution but I have no more idea. This is my problem.
I'm trying to create a macro to automatically define new other macros to write references in a document. I want to ...
15
votes
2answers
323 views
Difference between \let\foo\relax and \def\foo{} for disabling
When I want some macro to (temporarily) do nothing, I normally write
\let\foo\relax
But somebody asked me why I don't just do
\def\foo{}
and I realized I couldn't answer his question.
So, I ...


