{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
15 views

Insert line break if content doesn't fit empty space in last line of paragraph [duplicate]

I would like to typeset a small phrase aligned at the right in the last line of a paragraph. Ex: This is some text in with a short enought line this is the phrase The code: ...
3
votes
2answers
90 views

How to print the content of a macro to the terminal

I am writing letters of application to various companies and to speed up the process I have few macros defined in my .tex file i.e. \def\company{ Company name ABCDEF } I know that one can do ...
2
votes
0answers
39 views

Basic definition of variables for use in resume

I'm working on writing my resume in a LaTeX and hoping to implement some commands to automate section styles (though I am by no means planning to write an entire class). For example, I'd like to ...
1
vote
0answers
72 views

Terminate and Start and environment from within the environment

How can I terminate and resume an environment by another environment? This also seems to have broken the resume feature which was resolved in Define a List that is Always Resumed. The code ...
0
votes
1answer
51 views

Using \lstinline inside a new command or environment

I use the listings package to render code in LaTeX documents. I am trying to define a new command or a new environment that uses \lstinline inside. I have read numerous questions about this on ...
4
votes
1answer
140 views

How can I simply add comments and to-do's with a symbol in the margin?

I love latex but I'm tired of sending my comments to a document by mail, instead of writing them down in the document. I'm looking for a simple (as simpler as posible) way to add a block of text, ...
3
votes
0answers
143 views

TeX/LaTeX macro to find out where am I in a tabular

Do you know a macro/command which can tell me where was it called in a tabular environment? Specially, i wish a macro which executes \commandA if I called it in the first cell of a row (or after a \\ ...
12
votes
3answers
233 views

Trailing space in parameter delimited with \par

I just realized that when I use \par as a macro parameter delimiter the parameter then contains a trailing space. MWE: \def\test #1\par{\def\param{#1}} \test test \hbox{\vrule\param\vrule} % ...
0
votes
1answer
14 views

Command for function of function? [duplicate]

If I'm trying to write f of g where f and g are functions, what is the command for the of symbol?
5
votes
4answers
110 views

Define newcommand with multiple sorted mandatory arguments that can be empty

I'm trying to define a command that will take 3 arguments each one possibly empty. An empty argument will slightly modify the output. Let me give a non-working example : \newcommand{\foo}[3]{ ...
3
votes
1answer
67 views

Protect the font format in macros

I define a macro (\chit) that uses one font (sc), and the macro is used in another macro that textbf in the implementation - \textbf{Q\thequestion: #1?}. \documentclass[12pt]{article} ...
5
votes
1answer
69 views

renewcommand of variable inside package's function

I am using the tikz based neuralnetwork library and I am trying to change the variable nnlinklabelextrastyle to modify the font of of the edge labels, but I can't figure out how to target ...
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
99 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
65 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
40 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
77 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
147 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
54 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
38 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
49 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
65 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
41 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
182 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 ...