Questions tagged [def]
The def tag has no usage guidance.
36
questions
0
votes
1
answer
26
views
Remove newline from input
Is there a way to remove a single newline character from an input? Something like this
\edef\test{\removenl{ Hello World %
}}
% \test should have ` Hello World `
Context: Consider a file.txt that ...
2
votes
3
answers
263
views
Defining a custom if command
In the following minimal example, I am able to define a custom \if* command based on ifcsname, however when I use it inside \loop construct I get Extra \fi errors
\documentclass{article}
\...
2
votes
1
answer
103
views
Create new count with \def
I have the following macro/command:
\def\definenewcounter#1{\newcount \csname#1\endcsname}
It is supposed to create a new count with it's name being whatever argument 1 is, but it is throwing errors. ...
4
votes
2
answers
109
views
Redefine the command \cite to be able to use an additional syntax
Background
The package amsrefs redefines the command \cite so that one can use the syntax "\cite{book-name}*{optional-argument}" to produce (essentially) the same output as the usual "\...
1
vote
2
answers
35
views
Weird Question with def, and condition
MWE:
\documentclass{article}
\def\ENLANG{english}
\def\FRLANG{french}
\def\LANG{\ENLANG}
\begin{document}
\if\LANG\ENLANG \ENLANG \else \FRLANG \fi
\ifx\LANG\ENLANG \ENLANG \else \FRLANG \fi
\LANG\ \...
0
votes
2
answers
59
views
def inside def gives an error when used with ref
I want to define a command that returns a label to use with \ref, but it requires using \edef to expand another command. However, I am getting several errors starting with Missing \endcsname inserted. ...
0
votes
0
answers
62
views
pandoc --metadata-file yaml on xelatex and debian - how to debug?
Please guidance and help.
How can I debug a pdf generation from a latex template (using xelatex)? I am having trouble bringing metadata from yaml files, is there a way to see log, aux, out files when ...
3
votes
3
answers
136
views
\def and \edef: Expansion for one level, not more
I want to save the content of a macro (which may contain text and other macros) for later use and without full expansion.
\def\mcr{a}
\def\textandmacro{sampletext \mcr} % this content i want to recall ...
0
votes
0
answers
32
views
TikZ: collecting defined coordinates in a list
I want to collect previously defined coordinates in a list and print them later in a \foreach-loop for debugging purposes.
The following MWE shows the list \points which ideally should be defined and ...
0
votes
1
answer
56
views
Using \protect to generalise definitions of starred commands?
This very helpful answer led me to define my own starred commands. However, in order to use my commands in, for example, headings, after a round of strange almost frightening thoughts, I managed to ...
0
votes
2
answers
77
views
How do you create a variadic new command?
The word "variadic" is used for functions, and commands, which can accept any number of input arguments.
Below, we see an example of a custom command which has three inputs:
\newcommand{\...
2
votes
0
answers
48
views
Problem with citation of authors having user defined command in their names
I have a problem using polski package simultaneously with imakeidx and biblatex.
I only use the command \dywiz from package polski which is defined as \def\dywiz{\kern0sp\discretionary{-}{-}{-}\...
4
votes
1
answer
324
views
How to get rid of \def
I was recently required by a journal to getting rid of \def in the definitions of my personal macros. It turns out to be not-so-easy and the naive replacement of \def by \newcommand does not always ...
0
votes
3
answers
132
views
How to understand "\appendroman#1#2#3" on page 41 of The TeXbook?
At the bottom of page 41 of The TeXbook, there is a question:
Define a control sequence \appendroman with three parameters such that \appendroman#1#2#3 defines control sequence #1 to expand to a ...
2
votes
1
answer
65
views
Applying newcommand/def to subscript whenever one is provided
I have defined a \blue command which I often use with subscripts, e.g.
\newcommand{\blue}[1]{{\color{blue} \textup{\textbf{#1}}}}
\blue{v}_{\blue{ij}}
Question: Is there a way to define \blue in such ...