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

1
vote
1answer
48 views

Convert text from mixed case to start case

I'd like to change the capitalization of a macro from mixed case to start case. Let's say the following macro is already defined: \newcommand{\tostring}{toString} I can change the first letter to ...
2
votes
1answer
109 views

Command macro for an environment

How can I define a command macro using \newcommand so that the argument to the command is surrounded by an environment?
2
votes
1answer
41 views

table layout inside a newcommand

I wonder if I can define something similar to the \newcommand that places the values inside a pre-defined table (tabular) template. If you see the table above, imagine you would duplicate that many ...
1
vote
0answers
48 views

How to pass a color as an argument [closed]

Before explaining my problem, sorry if this is a repeated question, but I was not been able to find one answered/asked question in which the problem was the same as mine. In order to create a ...
3
votes
1answer
88 views

Bulk letter, “loop” doesn't work, “read to” doesn't work

Original Text below Edit: I solved it with endless googleing and help from here. Here is my theory: the typos caused expandafter to fail, which caused a dismatch between the chopline command and the ...
4
votes
1answer
62 views

Can't use macro in square brackets

I've made a matrix in a beamer presentation and I'm trying to style the nodes. \newcommand\foo{row 1/.style={inuse}} \begin{frame}{Chunks} \tikzset{ inuse/.style={text=red}, ...
2
votes
1answer
87 views

Get key value of command

i'm beginner in Tex and i have tex file \documentclass{article} \addtolength{\jot}{1em} \begin{document} \begin{verbatim} \end{verbatim} \begin{chestnutStem} In the following figure, if the ...
8
votes
3answers
491 views

Repeat characters n times

I wanted to create a new command, which allows me to repeat any characters I want for n times. After some searching and trying, I came up with this: \usepackage{multido} \newcommand{\myrepeat}[2]{% ...
6
votes
3answers
121 views

using csname to define intern commands(variables) and their setters

I want to define some macros to create texts in different languages; the command is \newlang which creates an invisible macro or variable to store the text of the specific language and a setter to set ...
3
votes
1answer
43 views

Passing a newcommand with one argument to another newcommand

I am wondering how to define a new command A with another new command B (which has one argument x) as the argument of A. Here is a simple example: \documentclass[english]{article} ...
3
votes
1answer
22 views

How to get xcolor colour mixing to work in newcommand

I want to set the colour of a table cell using the argument passed into a command, but it doesn't seem to have any effect. Here's my code: \PassOptionsToPackage{table}{xcolor} \documentclass{beamer} ...
4
votes
1answer
40 views

Line breaking in \newcommand

I defined a new command for highlighting some text parts: \newcommand{\keyword}[1]{\colorbox{black!5}{#1}} Unfortunately, when the text becomes to long it overlaps my margins. The keyword ignores ...
1
vote
1answer
24 views

pgfplots filter table with float content and conditions

I want to filter some data for a plot, and so far the best thing I found is this here. This is the relevant code from the mentioned question: \pgfplotsset{ discard if not and smaller/.style n ...
2
votes
1answer
67 views

Replace undefined reference ?? with custom text?

I'm using luatex and the cleverref package while writing a large document. I often only want to compile only parts of it, but I'd like my output to be a little nicer when I only compile a single ...
6
votes
1answer
47 views

Keep babel's automatic spacing in \newcommand

In French, there's a narrow non-breaking space before ":". These are automatically added by the babel package, of course. However, I noticed something strange: the following macro ...
1
vote
1answer
42 views

Styling \Blindtext and \blindtext (aka renewcommand with optional arguments)

I am using blindtext package to draw out how the layout of the document will look like and then swapping the "dummy" parts with real text. Problem is that I would like to give some style to these text ...
1
vote
1answer
38 views

Generate list of macros in the output

I have several macros defined in my document. \newcommand{\pa}[1]{\left(#1\right)} % enclose with parentheses \newcommand{\bra}[1]{\left[#1\right]} % enclose with square brackets ...
0
votes
0answers
37 views

Issue with underscore inside a newcommand for math mode

I have this new command as a shortcut for math mode: \newcommand{\m}[1]{$ #1 $} I get the error Missing { inserted error on lines including underscores like \m{f_1(x) = 10} and \m{f^2(x) = ...
6
votes
3answers
141 views

Make Characters Active via Macro in Math Mode

I am trying to make characters active in math mode, but can't seem to get past the most basic of examples. I would like to define a macro which is passed: the character to make active and the ...
1
vote
1answer
66 views

Macros just for certain number of lines

I want to write a macro that will do certain things with a fixed number of lines coming after this macro. For example, how to apply \rightskip=2cm to the first four lines of a paragraph How to ...
2
votes
1answer
37 views

using \dq in \subsections: has an extra }

I defined \newcommand{\q}[1]{\dq#1\dq} for the easier usage of the quotes. Now I want to make subsections containing quotes... \subsection{ \q{build} } This line above causes an error for l.42 ...
0
votes
0answers
53 views

New command to append endings on labels via \gls

The \gls-like commands of the glossaries package allow to append a text after the referenced label. In addition, the package includes the command \glsaddstoragekey to add additional informations to ...
2
votes
1answer
44 views

Modifying \coadvisor command

I would like to modifying the command \coadvisor in my thesis. Now when I use it I get: Co-orientador: Fulano de Tal After modification, I would like to get: Coorientador: Fulano de Tal ...
1
vote
0answers
21 views

Making csv2latex work with OSX El Capitan and TexMaker

I have encountered several difficulties making csv2latex work after excel2latex mysteriously failed after having worked fine for 2 years (no upgrades of office or anything)... I am using TexMaker as ...
4
votes
2answers
51 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
39 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
72 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
80 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 ...
1
vote
1answer
31 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
29 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
459 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
57 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
46 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 ...
3
votes
1answer
37 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 ...
1
vote
1answer
71 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
48 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
35 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
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
38 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
109 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
68 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 ...