{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
2answers
76 views

Newcommand inside foreach: multiple arguments and minipage environment

I am trying to define multiple, sophisticated newcommands within a foreach loop. This sounds so simple, but why is it so hard ? Naive attempt: \documentclass{report} \usepackage{tikz} \foreach \i ...
2
votes
2answers
56 views

Tikz macro with calculation error

I'm very new to this so bare with me. To get the hang of macros I wanted to write a simple command to draw a square in tikz. Now I know there are a lot of ways to do this, but I want to be able to ...
2
votes
1answer
73 views

Formatting matlab code within a macro

I know there have been a number of posts relating to this topic, in particular this one, but I find it impossible to believe that it's simply impossible to do the following incredibly basic thing ...
3
votes
1answer
90 views

ifthenelse in Latex

I have a table in Latex and in the left part of it I have an empty boxes (\Square), I want to replace them to the \xBox in case if the certain value has been picked. I wrote command \newcommand{\...
1
vote
1answer
206 views

After using \newcommand, Undefined control sequence error persists

I am using IEEEtran for a conference paper. When I try to define the \vicon seen in the code, I get an Undefined control sequence error. Although not shown in this code, the same error pops up for ...
0
votes
1answer
31 views

\newcommand for the row numbering

I want to have an automatic numbering of the rows in my table and I have a command for that, but it doesn't work correctly and I don't know how to fix it. Can someone help me to rewrite it? \...
3
votes
1answer
63 views

How to set default value of optional argument exactly in function?

I have two problems. I have an mechanism. It gives me correct number of lines, which I should make narrow (I have it in \setcounter{ct}{...}). And I want to teach \addpicture that skill and use it ...
17
votes
2answers
479 views

Does the use of macro in LaTeX slow down the compilation process?

Use of macro eases document preparation, further modification, uniformity maintenance, just to name a few of the enormous benefits we enjoy. But does the use of a macro slow down the compilation ...
0
votes
2answers
138 views

Run commands sequentially inside TeXStudio script

I'm trying to set up a macro to set up git repo for version control, so that I don't have to resort to manual terminal commands every time. Commit & push scripts are ready and working, it's ...
0
votes
2answers
61 views

reverse expansion order with optional parameters

Trying to implement a command with more than nine parameters (that also reverses things about) when there are, e.g., 8 of them, the first invocation is temporarily saved with \def\mytemp{\mycommandtwo{...
3
votes
1answer
39 views

Tex csname index off by one inside loop

I'm trying to write a write a simple implementation of a list of notation (more as a technical exercise than for actual use). I've run into a rather strange issue with numberings. The following is my ...
2
votes
1answer
106 views

Math mode macro in TeXstudio

I want to set up a macro in TeXstudio for math mode which displays $*$ and places the cursor at position *. So far I have tried using $%|$ but upon triggering, this macro does not allow text insertion ...
6
votes
1answer
49 views

Package for special treatment of sequences of capitals

For linguistic writing, I frequently deal with input data where sequences of capitals should be typeset not as capitals, but should be treated specially, e.g. be typeset in lower case, small caps. ...
2
votes
1answer
37 views

Redefine hbar to work in super- or subscripts

I can redefine the \hbar command to use the "h" from the current math font as follows \renewcommand{\hbar}{\raisebox{.5ex}{\rotatebox{15}{--}}\hspace{-0.5em}h} For example in Times New Roman this ...
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
105 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
69 views

Basic definition of variables for use in resume [closed]

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
77 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 \begin{...
0
votes
1answer
66 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
142 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
146 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
244 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
16 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
117 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
73 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} \usepackage{...
5
votes
1answer
82 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
66 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
57 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
106 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
86 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
65 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} \usepackage{...
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
117 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
188 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
285 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
44 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: \documentclass[...
7
votes
2answers
351 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
151 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
63 views

New commands suppress other commands [closed]

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
60 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
72 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 right\}....
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} \def\fn#...
3
votes
2answers
81 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
30 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
39 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
82 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
88 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} \newcommand{\fund}[...
7
votes
4answers
261 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. % Non-...
2
votes
1answer
58 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
35 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 \ ...