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

5
votes
2answers
113 views

Defining a command and its starred version with different number of arguments

I want to create the commands: $\vecbi*{A}{s}$ and $\vecbi{A}$ To write bold vectors in my text. However, I have tried the following code, but I am still stucked without a solution. \makeatletter ...
4
votes
1answer
104 views

problem with newcommand with line break \\ and tabular inside

I define a new command \nonBranchingRule that takes 3 arguments. Intuitively, it defines a rule where the last argument is a comment (optional argument) for the rule. I want to place the comment under ...
2
votes
2answers
66 views

new command definition brings extra space

Sorry for my original example code can not relect exactly what I mean. I have made a new one. I am trying to define a new command, but it seems some unwanted extra spaces are generated together. ...
12
votes
3answers
345 views

Explain this macro: double hash with no number, \ialign

This macro is quite old, and I don't know plain TeX very well. MWE: \documentclass{article} \setlength{\unitlength}{0.06em} \newlength{\cellsize} \setlength{\cellsize}{18\unitlength} ...
3
votes
1answer
67 views

Parse numerical value from glossaries variable

Can I parse the text returned from \gls*{...} and get latex to recognize it as a numerical variable so that I can use it in a calculation? This calculation could be done using calculator, fp, calc or ...
2
votes
1answer
39 views

Count and Show Compile Error

\documentclass{article} \def\ad#1{$^{#1}$} \def\aff#1{$^{#1}$} \def\address#1{#1} \def\dept#1{#1} \def\inst#1{#1} \def\cyname#1{#1} \def\country#1{#1} \def\pcode#1{#1} \def\stname#1{#1} ...
2
votes
0answers
47 views

How can I “outcompile” macros? [duplicate]

Let's say I have have the file asdf.tex which contains the code: \documentclass{article} \newcommand{\asdf}{blabla} \begin{document} \asdf is very cool! \end{document} How can I compile my ...
3
votes
1answer
42 views

macro (newcommand) Why some text is not getting in the output ?

I want to repeat some text and tables on the same page. I am trying the code given below, but it is printing only once and then again it is not printing the ruler at the end. The complete code is ...
4
votes
2answers
58 views

Using \not command with custom-made ones

Task is simple. I have a command (alias of sort of a complex expression. I'm using frequently), and sometimes I'd like to put \neq instead of \eq. I can simply add third arg with default value, but ...
3
votes
2answers
153 views

Substitute string that contains a backslash

I need to create a function that will transform a string such as: Hello\textbackslash{}Bye into this: Hello \\ Bye I have tried using StrSubstitute (from the xstring package) without success. I ...
1
vote
1answer
57 views

Access specific glossary fields without triggering first usage

I would like to know if any of the fields that are manually configured during the creation of glossary entries can be accessed manually/deliberately in a macro or newcommand - possibly of the form: ...
4
votes
1answer
61 views

How to programmatically comment out environments?

I write multiple-choice exams using the Exam class and I would like to be able to print the exam without printing the answer choices. At the moment, I manually comment out everything from ...
0
votes
0answers
14 views

\newcommand to remove text and replace it by “empty” text [duplicate]

I am defining a command \newcommand\delete[1]{\text{}} % delete to replace a block of text in my latex document. It works almost fine, except that it inserts a space instead of "nothing". To be ...
9
votes
2answers
91 views

Splitting macros to individual tokens/characters, with catcode (to debug conditionals)?

Consider this MWE, modified from ifthenelse equal string comparison fails: \documentclass{article} \edef\test{german\relax} \edef\curentry{\string german\relax} \typeout{test: \meaning\test, ...
10
votes
1answer
443 views

Create a date X years later than today

I am trying to create a date X years later than \today. My dates have the following format : dd/mm/yyyy. I tried the advdate package, yet when the month is in [1-9] range, it returns the number of the ...
3
votes
2answers
79 views

Adding \comment or \begin{comment} to \AtBeginDocument?

For Partial compilation commands/environment?, I would like to add \begin{comment} or \comment at the start of the document (so I could turn it off elsewhere in the code). So, even if in the larger ...
2
votes
1answer
66 views

Nested conditional glossary terms using Glossaries \ifglsused in \newglossaryentry

If I want to conditionally expand a glossary entry based on or related to another glossary term, I find the conditional \ifglsused{}{}{} statement is very helpful. To satisfy parent modifications ...
4
votes
3answers
143 views

How to define _or_ redefine a command (mixing \providecommand + \renewcommand)?

In some situations I wish there was a way to define a command \tmp so that if \tmp does not exist: Defined \tmp if \tmp does exits: Redefine \tmp My current approach is simply to use either ...
4
votes
1answer
96 views

Use newcommand in newenvironment

I want create an environment with newenvironment that does the following: it evaluates the height of the environment and then prints it as many times (textheight/height) as will fit upon one page. ...
10
votes
1answer
112 views

Use luatex to \let command to other

still looking for LuaTeX, I understand how I can execute Lua code insided TeX code (via \luadirect) but not how I could execute TeX code inside Lua code. I explain : I would like to make a series of ...
4
votes
2answers
108 views

newcommand: passing coordinates as a single argument

Is it possible to pass an array argument to newcommand and then access those individual array elements? For example, if I wanted to multiply the third element of the array (first argument) by the ...
12
votes
2answers
226 views

Assertions in Latex

I am writing a long latex document and use many macros for defining mathematical symbols. I would like to ensure that there is no clash in the notation. For example, something like ...
1
vote
0answers
162 views

Compiling tex file using pdflatex and cmd - strange behavior [duplicate]

I'm have a really strange problem here. I have a tex file which I compile to a pdf file using the pdflatex.exe which comes with MikTeX. The Problem is now that it seems a problem when the tex-file ...
1
vote
1answer
33 views

Expand macro at call site only

I want to draw a tree where each edge has a certain weight visualized through both the line width as well as a label on the edge. Using TikZ, this is pretty easy: \documentclass{standalone} ...
5
votes
1answer
139 views

Return Real from Macros

I want to build macros that return real values. For example, I would like to have something like following pseudo-code: \documentclass{article} \usepackage{etoolbox} \usepackage{calculator} ...
5
votes
1answer
63 views

Setting a specific key (and value) depending on state of \if macro

This question is basically a follow-up of two older questions I posted a year ago, but actually is a consequence of trying to find a solution to this question: Use toggles in biblatex ...
9
votes
2answers
67 views

Transform \sepfootnotecontent into an environment

I am currently cleaning the code of a 1000-page book that contain hundreds of very long footnotes so I decided to move them into separate files using the sepfootnotes package. It’s easy to use: ...
1
vote
1answer
55 views

How can I create a command or environment that starts and stops verbatim?

I am writing a simple LaTeX guide, aimed at editors of a student paper. The paper is for students of mathematics and physics at my university, and so we use LaTeX. Anyways, I want to include lots of ...
3
votes
0answers
59 views

endfloat and \newcommand incompatibility

I have a lot of figures and tables defined using \newcommand{\NAMEOFTABLE}{\begin{table}...\end{table}} and I would like to use them with endfloat package. Here is a MWE that demonstrates the ...
2
votes
1answer
63 views

Command not redefined

I am writing a custom package and would like to set the fraktur Real and Imaginary symbols to the standard \mathrm{Re} and \mathrm{Im}. I am trying to redefine them the standard and recommended way ...
11
votes
1answer
155 views

Why this output using \string on the empty csname

How does this exactly work? \expandafter\string\csname\endcsname I don't know what I would expect to come from there, but definitely not \csname\endcsname_ where _ is a space. I thought ...
1
vote
1answer
50 views

Compiling error after I comment a meaningless statement

I am making a multi-language document. With the big help of Mr. Steven B. Segletes, I am able to deal with several languages mixed document, which can only output in wanted one or several laguages. ...
2
votes
1answer
40 views

Guides to Writing Macros with Error Message

I'm trying to write \newcommand macros that will check the user's inputs to arguments and return an error message if an error (for example, value out of range) is found. Is there a good reference? ...
3
votes
0answers
55 views

Aliasing a variable argument command into tabular enviroment [closed]

I am making a multi-language document. With the big help of Mr. Steven B. Segletes, I am able to deal with several languages mixed document, which can only output in wanted one or several laguages. ...
7
votes
3answers
379 views

howto convert roman into arabic numeral

I know that there is a command \romannumeral that converts numbers in roman numeral \romannumeral3 gives iii Is there a converse like \arabicnumeral{x} that should produce 10?
6
votes
2answers
219 views

Spaces added to occurrences of “{}” in the TeX code

Can anyone explain how to get rid of spaces that are automatically added around arguments provided in curly braces in the main part of a text? Here's a minimal example: \documentclass{article} ...
1
vote
0answers
48 views

Write a class with different code for different version

I want to write a report-like class (maybe based on KOMA-Script). My problem is that the layout will be evolving and maybe the features of the package to. I would like to know if there is an easy way ...
2
votes
1answer
54 views

Use macros within listing

I would like to use I macro I have defined (including mathematical symbols) within a listing environment. However, the following code prints "\foo{x}" rather than "bar(x)". Is there any way of ...
5
votes
2answers
336 views

Redefine \emph to be both bold and italic

I'm trying to redefine the \emph command to make text bolded in addition to being italic, but when I use \newcommand{\bfemph}[1]{\textbf{\emph{#1}}} \renewcommand{\emph}[1]{\bfemph{#1}} I get an ...
4
votes
3answers
128 views

Set up class to have a variable that can be used across document

I know I can create a new command like so: \newcommand{\myname}{John Doe} \myname would then display "John Doe", However I would like to be able to do something more dynamic like the fallowing ...
9
votes
1answer
78 views

Automate correct spacing after ! in math mode

$(2n)!/\bigl(n!\,(n+1)!\bigr)$ $${52!\over13!\,13!\,26!} + 33!! - y$$ $(2n)!/\bigl(n!(n+1)!\bigr)$ $${52!\over13!13!26!} + 33!! - y$$\bye How could we automate the spacing after !? As explained in ...
2
votes
1answer
78 views

Redefine a primitive parameter

I want to redefine a primitive parameter as a macro, and make the macro behaves the same as the primitive parameter in some situations. \tracingcommands = 1 \the\tracingcommands ...
0
votes
0answers
68 views

Alias normalbaselineskip to \\ in a tabularx environment

I'm still on my way to my key:value table, and this time, I'm trying to alias [\normalbaselineskip] to \\. I still want to use the standard \\. What I want is to consider \\ as [\normalbaselineskip] ...
0
votes
0answers
50 views

Determine math font, fontsize and shape latex

How can I determine the default math font, fontsize and shape used in a document? I know I can use show for instance but I do not know which macro I need to call I want to know this because I want ...
6
votes
2answers
197 views

How to define macros in order to reuse key-value parameters?

I use the listings package to typeset code in my document. I have defined a new environment via \lstnewenvironment in which I use \lstset to set a large number of options through a list of key-values. ...
1
vote
1answer
31 views

Custom Commands for format modifiers

How would I implement this as a \newcommand \LARGE \ <Text> \Large Document class is a article. Essentially what I am aiming for is to use a command such as \formatlarge{<text>} that ...
3
votes
0answers
80 views

Convert Plain TeX automatic table generation macros to LaTex [closed]

I have written code, given at at the end of the post, to typeset exams and quizzes in plain TeX. A typical test would be typeset using: \def\CLASS{Math 111} \def\TERM{Spring 2015} \def\TITLE{Quiz 3} ...
11
votes
3answers
168 views

Use a macro to define a \NewDocumentCommand macro without backslash

Or as, Werner simplified it: "How to define a command without backslash in xparse". Background: I am trying to set up a macro to define a macro for me (which will also do some other things which ...
0
votes
2answers
72 views

Change \textheight in function of width

Good day. I want define an environment that change the text height in function of the width \documentclass[a4paper]{book} \usepackage{lipsum} \begin{document} \the\textwidth---\the\textheight ...
2
votes
0answers
90 views

soul for text highlighting, microtype for letterspacing, and xspace: incompatibility

I am trying to use soul for highlighting text and microtype for letter spacing (and other things). But I cannot get the two to work together nicely when I include xspace (I use this mainly for ...