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

4
votes
1answer
64 views

Redefining eplain’s \numberedfootnote within a plain tex document

eplain provides a macro \numberedfootnote which, as might be inferred from the name, produces a raised number followed by the footnote text with the number increasing by one each time it is called. ...
3
votes
1answer
54 views

Import several parts of file at once

As a follow up to this Question Situation I would like to create an excerpt from a script that I have TeX'ed as a compendium of the most important statements (theorems & definitions). I seek ...
4
votes
1answer
98 views

Robust commands

What is the primary reason to \protect new definitions or macros, or use \DeclareRobustCommand rather than just \def? (Assuming one does not redefine things by accident.) If it is primarily to do with ...
1
vote
1answer
59 views

Left Content Bar/Area

I am working on a template for papers and documentation. Sometimes, the authors have "key facts" or other items they wish to callout in a left content bar (xxxx is left bar, ccc is main content): ...
2
votes
0answers
38 views

Trouble with frame in newcommand

I'm making a slideshow with LaTeX beamer class like this : \documentclass[xcolor=dvipsnames]{beamer} \usepackage[french]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} ...
2
votes
1answer
38 views

How to color text inside of a \def

I am trying to color some text inside an xdef command. I am getting the following error: Use of \@undeclaredcolor doesn't match its definition. Does anybody know how to resolve this? Thanks! edit: ...
1
vote
1answer
76 views

\newcommand is undefined control sentence

I am trying to create a very simple new command such as follows: \newcommand{\rvm}[1]{\textcolor{red}{#1}} My text is organized in a main tex file and the sections are in other files. I call them ...
9
votes
1answer
184 views

How does \delimiter work? How does it convert its argument into character(s?) and why?

studying the definition of \lvert (which just made me finally understand what does mean \@xp\@gobble and how it works \o/), I found the \delimiter command, with a numeric argument advanced by ...
10
votes
3answers
266 views

How to only display the mantissa of a number (without the exponent part)

Is there any command that allows us to extract the mantissa of a number like 2.36e6 so we can get 2.36? Something like this: \mantissa{2.36e6}
3
votes
1answer
40 views

TeX \@for loop within a section title

I am creating a macro for turning a list of files into a comma-separated list of monospaced file names, and using it as a heading. I have written a short script for doing so: MWE: ...
7
votes
2answers
347 views

Why is escaped # breaking my command?

I have created the following two commands: \newcommand{\termExplanation}[1]{\item[#1]\label{#1}} \newcommand{\newTerm}[1]{\hyperref[#1]{\emph{#1}}} In my text, I use \newTerm{Term 3}, and somewhere ...
2
votes
2answers
146 views

Create user defined command

I am new to Latex, I need to create a user defined command or Macro. I need to print unix shell commands on a pdf, the code looks like below \begin{lstlisting}[language=bash] $sudo apt-get install ...
1
vote
0answers
53 views

New commands suppress other commands

I adapted the new commands wrote by @Alan Munn, to produce LaTex representation for some African language symbols. However, the new commands seem to suppress the use of other symbols, which worked ...
1
vote
2answers
51 views

Create hint for my commands

I am creating a .sty file and I want it to be user friendly. Is there any way to create hints for my own commands such as I see it in Kile for standard LaTeX commands? I'd like to have a command ...
2
votes
1answer
61 views

Define a LaTeX command that takes character as argument, instead of taking it in { }

I want to define a command that takes two of its arguments as the first two characters after; just like \left( and right) take the first character after them, even if they're braces left\{ and ...
4
votes
1answer
37 views

LetLtxMacro not working as expected

If the lines commented out are substituted for those above them, the index is not set. Why not? \documentclass{article} \usepackage{imakeidx} \usepackage{hyperref} \usepackage{letltxmacro} ...
3
votes
2answers
61 views

creating newcommand on my own package

I'm sure I'm doing something wrong, but can't find what exactly. Writing my thesis I created a package for my constants, they work OK: \def \earthRadius {\num{6.371e6}\si{\metre}} \def \lightSpeed ...
3
votes
2answers
29 views

Adding pagenumber to crossreference command

in "making external references stick out" I found the new command written below very helpful. Although I would like to add a pagenumber to the external file in the \myautoref command, and can't seem ...
1
vote
1answer
24 views

Default behaviour when missing argument in \newcommand

I'll try to be clear because this is not what I am looking for. What I'm trying to do is to define a new command that takes one argument but has a different behaviour whether that argument is or is ...
1
vote
1answer
78 views

Turning off hyphenation and redefining the typesetting of italics and bold

I want to emulate under ConTeXt the manuscript format provided by the sffms LaTeX package: http://www.mcdemarco.net/sffms/ It provides, roughly, these features: Double spaced manuscript 12-point ...
5
votes
2answers
73 views

How to create comma-formatted number from macro output value?

In the following document I would like for the numbers to have a thousandths separator comma. \documentclass{article} \usepackage{totcount} \begin{document} \newtotcounter{fund} ...
7
votes
4answers
250 views

Macro: Expand different depending on pattern?

I want to write a macro that expands differently depending on the pattern following it. Specifically I want to use it to allow a more readable notation for quantum mechanical states, e.g. % ...
2
votes
1answer
52 views

Multiple Space Hacks Generate More Space

This is a follow-up to a recent post: Creating removable comment command without extra space. I'm trying to do a common thing: make a removable comment command so contributors to a document can leave ...
1
vote
1answer
30 views

Can I inject \xspace in all commands from the complexity package?

The complexity package is a very useful one for a Computer Scientist. Recently, I've discovered the xspace package, which provides the \xspace macro that helps defining macros that do not need the \ ...
3
votes
1answer
48 views

Making a long macro/shortcut in Latex

I was wondering if it was possible to make a big macro, for inserting figures? I wanted it to contain: \begin{figure} [H] \centering \includegraphics[scale=0.8]{#FILENAME} \caption{#FIGURECAPTION ...
2
votes
1answer
47 views

Space lost after \newcommand [duplicate]

I use the initialism "CE" a lot in my thesis, both in an out of equations. I find that the letters are too far spaced for my liking when used in an equation, so I use the \! command to reduce the ...
3
votes
1answer
55 views

Creating removable comment command without extra space

I'm trying to create a command we can use for comments in our document. During development, we want the comments to appear; for production, we want them to disappear. This is a common enough problem ...
3
votes
2answers
178 views

Is there a way to produce \cite{xx} as it is in the generated PDF file?

My thesis is written in many tex files and I would like to have it proofread. However, the proof reader is requesting the thesis in MS Word format. Although the generated PDF can easily be converted ...
3
votes
1answer
64 views

Add content to end of page

is there a simple way to add some content at the end of pages similarly to \AtEndDocument (for example something like \AtThisPageEnd) ? I looked at everyhook and everypage, but it doesn't look that ...
3
votes
1answer
75 views

How can I do unvbox when define macro?

This is another approach to solve the problem in question "How can I write to file part of text between two flags?". I try to "remember" parts of text to use them later. So, I do \newbox\@tmpbox ...
2
votes
1answer
93 views

Creating a heatmap using calculations and tabular environment

I know there exists pgf, and many people uses this to create heatmaps. I however am not allowed to use this package. I therefore want to create a command that enables me to color the different cells. ...
3
votes
1answer
50 views

Define a command that opens and closes an environment

I would like to define a command that, starts (\begin{...}'s it) an environment if not in such an environment, and closes (\end{...}'s it) it if in such an environment, for example: \myenum ...
8
votes
3answers
157 views

How to use \verb or something similar inside a \newcommand

The command \displaygraphics[width-1in]{figure=some_fig.pdf} will display a graphic. Sometimes I want to typeset when I do not have the graphics files available, so I want to do something like: ...
3
votes
2answers
172 views

Drawbacks of csname method to avoid spaces after command

I had a similar problem as this one: Space after LaTeX commands My first attempt was something like this: \newcommand{\satip}{SAT\textgreater IP} This leads to the known Problem, that spaces after ...
2
votes
0answers
42 views

Macro with \afterassignment syntax?

Say for some reason I want to make a macro with input stream behaviour mimicking that of \afterassignment and \aftergroup. Namely, I want to absorb exactly one token from the input stream following ...
3
votes
3answers
40 views

Macro expansion and biocon package

I'm using the biocon package to organize plants in an academic work. I created new taxons as needed in the text, for instance, the family. In the final chapter of the work, I have a large table (about ...
1
vote
1answer
52 views

Macro expansion ordering in tables

I've a large table (about 300 entries). Sometimes, I've a sequence of entries with the same value (for a given column). In such a case, I need to omit the value. All my values are stored in variables ...
4
votes
3answers
181 views

How to pass days to tikz calendar using macros

I'd like to pass to the calendar some day names using a personal command, so user can change the days easily and create a personal calendar. I defined the command \mydays with one argument, which is ...
2
votes
1answer
40 views

Font size macro in tikz font style

I have a set of tikz styles I use for multiple tikzpictures in my document. These styles are in nodestyle.tex. I can optionally modify the size in those styles by doing \newcommand{\trnodesize}{1em} ...
14
votes
3answers
796 views

How to produce this table in latex with inconsistent lists/items?

I want to produce the first two rows of this 5-column table in LaTeX: As you can see it is a special type of tables where we see: itemized lists inside but inconsistently, ie. column 4 all rows ...
3
votes
1answer
46 views

unicode-math and redefine a built-in math command

I'm trying to redefine a math command (let's say \int) so that it will always do more (let's say \int lol) using the following trick: http://tex.stackexchange.com/a/47353/15659 BUT, now I want to use ...
18
votes
4answers
590 views

Detect whether running on pdfTeX or Knuth's TeX for conditional include

Does anyone know a way to detect whether one is running in pdfTeX or Knuth's TeX? I want to be able to conditionally include extra features when a document is being built using pdfTex, but also ...
4
votes
0answers
26 views

Defining a command where the argument could contain percent signs [duplicate]

This minimal example won't compile: \documentclass{article} \usepackage{url} \newcommand{\mycommand}[1]{#1} \begin{document} \mycommand{\url{http://www.example.org/index.php?a=Hello%20World.}} ...
0
votes
0answers
22 views

Spacing between custom command and subsequent text [duplicate]

I have defined a custom command for the name of my project; e.g. \newcommand{\projectname}{Gizmo}. When I used the command in my document, I've found that I need to place a ~ after the command in ...
4
votes
4answers
167 views

Expandable macro with loops and advanced string functions?

This might be a very basic problem (as a follow-up to this question) but I cannot figure out how to do it: I need a macro \mycmd{sometext} that yields a string depending on the first character of its ...
1
vote
0answers
66 views

Problem with microtype's `\textls` and math mode

I have some issues with classicthesis' \spacedlowsmallcaps command that I could bring down to the following MWE: \documentclass{scrartcl} \usepackage{microtype} ...
9
votes
1answer
81 views

Using expanded macro as search pattern for \patchcmd

Is there any way to use the value of an expanded macro as the search pattern for etoolbox's \patchcmd (or xpatch's \xpatchcmd, etc), so that one can have some sort of a "dynamic" patch, by way of ...
4
votes
1answer
43 views

XParse: Command, which creates a command

SE, lately I'm playing around with expl3 and xparse a little and I encountered following problem: I want to create a command which creates a new command -- similar to this post. This is not as hard, ...
5
votes
1answer
42 views

macros - calling a command using an input variable

In the process of a project, I realized it would be helpful if I could do as follows. Say I have a list of different commands (simplified): \newcommand{\AA}{...} \newcommand{\AB}{...} ...
2
votes
2answers
64 views

How to automatically determine the remaining width of the text field in this form?

I have this form made with the aid of hyperref package using the form environment: \documentclass[pagesize=pdftex,DIV=16]{scrartcl} \usepackage{xcolor} \usepackage{hyperref} % ...