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

0
votes
0answers
16 views

Latex Macros: Local Variables and Path Names

I initially have a group of TeX codes that looks like so: paper.tex assignment.tex Where paper.tex is the main TeX and takes in the assignment.tex file and adds it in there. The assignment.tex is ...
1
vote
1answer
12 views

Create new fields in glossaries newglossaryentry

As an alternative to the question detailed Nested conditional glossary terms using Glossaries \ifglsused in \newglossaryentry I would like to add some fields to a glossary definition. Is this ...
1
vote
1answer
60 views

How can I wrap this code in a function?

I have a text that describes spell powers in a game. The following pattern is repeated for each spell: \documentclass{article} \begin{document} % Template for spell powers. \textbf{Small Heading} \\ ...
2
votes
0answers
37 views

Nested conditional glossary terms using Glossaries \ifglsused in \newglossaryentry

The ultimate reason I am over complicating the definitions of glossary terms is to try and prevent excessive duplication of glossary terms that may be built of each other. The problem: Sometimes ...
4
votes
1answer
141 views

Command to count characters in a specified string

Is there a way to count the number of characters in a specified string? Suppose I had the following code. \documentclass{article} \newcommand{\numchars}[1]{\noindent The string ``#1" has ? ...
3
votes
1answer
52 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 ...
4
votes
2answers
47 views

Defining own command

I'm trying to create a command to save me some heartache when writing the rest of this document. What I'm attempting to do is to create a command like \double{-}, which when used will produce: ...
4
votes
1answer
43 views

Command doesn't expand into other commands after string substitution

The MWE should explain it all (use LuaLaTeX): \documentclass[11pt]{memoir} \usepackage[T1]{fontenc} \usepackage{fontspec} \usepackage{xstring} \usepackage{easylist} \begin{document} ...
0
votes
0answers
42 views

Formatting multiple-choice questions

I require a question environment with the following characteristics: The prompt has to be set beforehand with \prompt{What is the answer?} because the environment has to accomodate other data such as ...
4
votes
2answers
24 views

Delayed expansion of StrSubstitute argument with active characters

This is an extension of my previous question. The accepted answer provided a way for me to delay expansion of a marked-up easylist list until the string was processed inside the environment. I'm ...
6
votes
2answers
80 views

Iterator-like command, where each use expands to an item from list defined earlier

What is the simplest way to create an iterator-like macro (in the functional programming sense) in pdfLaTeX? I'd like to predefine a list of elements (to simplify we can assume that it is plain ...
5
votes
1answer
35 views

Replacing an id (integer) with a string?

I have a tex document that contains sections that are automatically generated. These sections have strings that are observation IDs. I would like to have latex replace all occurrences of an ID with ...
3
votes
3answers
46 views

Creating a new list Environment, how to change the length of \items

The code for the environment is bellow, For the longer lines in \list item how do I change the length of the \items so that it lines up with the date? Basically I want a kind of "margin" that is on ...
0
votes
2answers
72 views

Redefining math symbols like \eta (with ensuremath)

An easy one: I would like to define a shortcut so that I can write \eta without having to enclose it in $\eta$. However, the naive approach will not work: \documentclass{article} ...
3
votes
1answer
39 views

Creating a command within a list

So I'm trying to create a simplified kind of list inside of an environment, so that calling one command will create an enumerated item and calling another will create a subitem. Here's my code: ...
11
votes
3answers
308 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} ...
5
votes
1answer
47 views

Why am I getting an error when using \renewcommand, here?

I try to type \renewcommand{\mr}{\mathrm}, so that I can then use \mr in my text instead of \mathrm. I get the error \mr Undefined. what is going on?
5
votes
2answers
96 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 ...
3
votes
1answer
91 views

Creating a Macro for an n-by-m Matrix in LyX

Specifically, I'd like to create a matrix such as $\left[\begin{array}{cc|c} a_{1} & a_{2} & a_{3}\\ b_{1} & b_{2} & b_{3}\\ c_{1} & c_{2} & c_{3} \end{array}\right]$ But in ...
4
votes
1answer
42 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 ...
5
votes
1answer
179 views

How to install LawTex on MacTex

I'm relatively new to LaTeX, and I run Mac OSX 10.9.1. I have the latest MacTex, and have used it with relative ease for basic documents. I'm a law student, and I'm required to make a complex document ...
0
votes
0answers
27 views

Remove italic style when using newcommand [closed]

Whenever I create a new command the text (as a string) displayed by the command is italic. A simple command: \newcommand{\helloworld}{Hello world!} results in Hello world!. Is there some way to ...
6
votes
2answers
134 views

Parse command argument separated by comma

I want to mix several language in my document, and the output language can be chosen according to corresponding variable I want to define this kind of command \mulan[en,fr,ru]{arg1}{arg2}{arg3} to ...
2
votes
2answers
55 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. ...
7
votes
2answers
59 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: ...
2
votes
1answer
32 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} ...
24
votes
7answers
2k views

Are there purely expandable variants of \MakeUppercase?

\MakeUppercase and \uppercase use TeX's uccode, and they are not purely expandable. Say, \edef\temp{\MakeUppercase{abc}} will fail. Sometimes purely expandable macros are very useful. They are ...
1
vote
1answer
35 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: ...
2
votes
0answers
42 views

How can I “outcompile” macros?

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 ...
4
votes
1answer
69 views

Use newcommand in newenvironment

I want create an environment with newenvironment which does the follow: it evalutes its height and print it many times (textheight/height) to fit one page. My first step: \documentclass{article} ...
3
votes
1answer
30 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
45 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
86 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 ...
4
votes
1answer
47 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 ...
8
votes
2answers
57 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, ...
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 ...
3
votes
2answers
44 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 ...
7
votes
3answers
323 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?
10
votes
1answer
399 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 ...
11
votes
1answer
130 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 ...
4
votes
3answers
82 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 ...
1
vote
1answer
37 views

Reassignment macro doesn't work inside title, if protected “works” but not styled

A handy macro egreg made works famously, but not so well in titles. \protecting it prevents TeX from dying, but then it seems to be hidden from \spacedallcaps. \documentclass{article} ...
3
votes
2answers
92 views

Automatically clean (numerous) customization macros gathered in an auxiliary file

I have to gather, in a single source file, source files from several authors, each of them with its own (many) \newcommand, \newtheorem, etc. I'd like to limit the scope of each of these ...
4
votes
2answers
73 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 ...
10
votes
1answer
94 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 ...
12
votes
3answers
198 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
43 views

macro for glossaries counter

I want custom my glossaries, and specially I want to have something like My glossary entry, its signification (see p. 1), if this entry mentioned only once or My glossary entry, its signification ...
15
votes
2answers
1k views

macro for empty nodes in tikz-qtree

I'm trying to define a macro for writing empty nodes in a binary tree using tikz-qtree. Referring to the code below, I want the string \missing in my code to be replaced by \edge[draw=none]; {} as-is ...
1
vote
0answers
131 views

Compiling tex file using pdflatex and cmd - strange behavior

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
28 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} ...