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

Label part in title and TOC “First part”, “Second part”, etc

I'm sure this question has already been asked and answered but I didn't know what to look for in the forum. I'd like to label my part title in TOC and in the beginning of the part itself like "First ...
7
votes
2answers
96 views

Define and set length in one command

Sorry this might be a very simple question, I am trying to cleanup a style file, and would like to write a command that basically runs the following code: ...
3
votes
2answers
28 views

combine enumeration of chapters

at the beginning of one part of my document I've got a tabular with some values and in the chapters afterwards I'll explain them. Some values need to be combined; so the chapters have to be ...
21
votes
1answer
518 views

I need to write extra version for blind people without braille

I am writing a small math script and I also need to make version for blind people, but without braille. For example \frac{1}{2} shouldn't be literal fraction, but it should be 1 over 2. Can I override ...
5
votes
1answer
49 views

Custom theorem-style environment

I use LaTeX to typeset notes and case briefs for law school. So far I have settled for a theorem-style layout for each case using thmtools. Here is a minimal working example: ...
5
votes
1answer
87 views

Always have the ring of the tensor product below the \otimes

I would rather have always have my tensor product look like $A\underset{R}{\otimes}B$ but still write $A\otimes_R B$. Is there a way to make this happen by some command in the preamble? (it's ok if it ...
7
votes
2answers
73 views

Why my parameter is set to zero when command is called from inner brace?

I have this piece of code: \documentclass{scrartcl} \usepackage{pbox,calc} \makeatletter \newcommand*{\strippt}[1]{\strip@pt#1} \makeatother \newlength{\pointsExo} \setlength{\pointsExo}{4pt} ...
4
votes
1answer
63 views

Resize tikzfigure in tcolorbox depending on height of tcolorbox

in my book I got many different type of boxes so I made some macros placing the boxes automatically according to their arguments. That's one of them. So far I made some boxes that have big "+" and ...
8
votes
2answers
151 views

How does expansion matter?

\newcount\@repeat% \def\repeat#1#2{% \@repeat#1\relax% \ifnum#1>\z@\relax% \advance\@repeat by -1\relax% \repeat{\@repeat}{#2}#2% \fi}% \repeat{2}{1}\\% \repeat{11}{f}\\% ...
6
votes
1answer
45 views

Thumb index for parts

I found this script but couldn't manage to adjust it for parts. Here's what I got so far: \documentclass{book} \usepackage{background} \usetikzlibrary{calc} \usepackage{ifthen} \usepackage{lipsum} ...
2
votes
1answer
53 views

How to get float numbers as parameter of \newcommand

I have defined a \newcommand function like into this code: \documentclass{scrartcl} \usepackage{pbox,calc} \newcounter{pointsExo} \setcounter{pointsExo}{4} \newcounter{pointsSousTotal} ...
0
votes
0answers
31 views

A command for including a folder of macros

Is there any command to include a folder of macros(such as sty,def,... files) in preamble like one for grapphics (\graphicspath{{figures/}}‎‎).
3
votes
2answers
48 views

Generate comma separated list with some non-empty strings

I'm trying to generate a comma separated list that uses strings that may or may not be empty. For example \mylist{\stringA,\stringB,\stringC} would expand to A, C if B is empty or B, C if A is empty, ...
0
votes
2answers
30 views

! File ended while scanning use of \@xs@testcase

my script produces this error: Runaway argument? \section *{Serumnatrium} \par \ib {Zweck}{ \el { * Wasserverteilung *\ETC. ! File ended while scanning use of \@xs@testcase. <inserted text> ...
2
votes
1answer
21 views

Can I count text as another category using TeXCount?

I am using TeXCount to perform a word count. I am using %TC:macro \macroname n (http://app.uio.no/ifi/texcount/faq.html#newmacro) to treat macros differently (for example I have a 'to-do' macro). Can ...
5
votes
1answer
34 views

Reduce source code of different tcolorbox macros

in my book I have a lot of tcolorboxes to use. They are slightly different so I added a macro that decides depending on the arguments, which tcolorbox to draw. Obviously that produces a LOT of source ...
4
votes
1answer
26 views

Large bibliography and local entries - Macro

I'm working on a (very) large document and I'd prefer to define my biblio entries as close as possible to the text I'm working on. Therefore, I'm using the "filecontents" package, to define separate ...
3
votes
1answer
41 views

convert string to active character

in my book I will have to itemize a lot of things in different lists. That's why I want to reduce my commands to a minimum. This script is just part of a bigger macro. \documentclass{book} ...
6
votes
2answers
124 views

How to rewrite this command using \newenvironment?

I once defined a customized latex command, which works well. And now I would like to convert it into a latex environment using \newenvironment command. However, I failed after trying several ways. ...
10
votes
3answers
695 views

Found it tiring to type so many \begin and \end

Is there some way to get rid of the \begin and \end's? For example, I need to type a small matrix, but I should type \begin{matrix}...\end{matrix}. I tried to define a macro ...
2
votes
1answer
23 views

How to pre-evaluate commands that are problematic for a specific environment?

More specifically, my problem occurs in the caption environment, but I imagine this applies elsewhere. I would like to insert the text generated by \suppOrApp and store it in the variable \sOrA: ...
4
votes
2answers
126 views

About \def\b*{\begin{align*}}

I want to make the code shorter. I defined the following pair of macros: \def\b*{\begin{align*}} \def\e*{\end{align*}} My point is that I saw this is a document, with \def\b*{\begin{eqnarray*}} ...
11
votes
1answer
84 views

What does \def\foo#{…} mean? [duplicate]

I came across this idiom recently: \def\foo#{...} That is, a hash but no parameter number. What might be the purpose of this?
2
votes
2answers
31 views

Multiple index keywords in a row

Is there a way to declare multiple \index{}keywords with a single command, instead of declaring them separately? More precisely, instead of doing \index{keyword1}, \index{keyword2}, ...
2
votes
1answer
54 views

Writing macros for tikz-cd arrow options

I'm trying to write a macro to let me write shorthand for tikz-cd arrows. For instance instead of having to write out the full command \arrow[swap, dotted]{r}{f^*} I'd like to have a shorthand ...
1
vote
0answers
19 views

Why is space inserted at beginning of table or figure caption when using macros to define caption label? [duplicate]

Here is my MWE. As you can see, the problem only happens when we use the macro \suppOrApp. \documentclass{article} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{caption} ...
0
votes
0answers
29 views

How to let latex only run one user defined command and save the ouput to a tax file [duplicate]

I want to let latex only run one of my defined commands and output results to a tax file. For example, the following tex file: \documentclass{article} \usepackage[usenames,dvipsnames]{xcolor} ...
5
votes
2answers
116 views

Loopy newcommand causes hanged processing

By a too quick search/replace of "mathcal" by "mc" I ended up with a loopy or recursive statement like \newcommand{\mc}{\mc} It seems to cause the compilation of my document to hang. Is this a ...
3
votes
1answer
38 views

LaTeX Macro for “code” style, underscore package and hyphenation

I'm looking for a way to nicely set code inside my document. I used \def\code#1{{\texttt{#1}}}, but it still allows the text to be hyphenated. To prevent that, I tried the advise from Prevent ...
5
votes
1answer
84 views

Latex \newcommand with python code inside

I'm extremely new to Latex. I'm using python package to insert graphics in a loop. What I can not understand is how I can transform this code \documentclass{article} \usepackage{python} ...
9
votes
2answers
97 views

Error when using defs inside a macro to write a row in a table

For the following MWE \documentclass{article} \newcommand{\cmd}[5]{% \def\tA{#1}% \def\tB{#2}% \def\tC{#3}% \def\tD{#4}% \def\tE{#5}% \tA & \tB & \tC & \tD & \tE \\ } ...
2
votes
1answer
108 views

How to insert table in Beamer frame

I understand from this question that using macros within Beamer frames might create issues. Still I don't understand where should I place the macro definition for \pgfplotstabletypeset. Please ...
223
votes
1answer
29k views

What do \makeatletter and \makeatother do?

Many TeX “hacks” begin with \makeatletter and end with \makeatother. What do these commands do?
6
votes
2answers
104 views

Using commands inside \url?

How does one use commands inside \url{..}? MWE: \documentclass{article} \usepackage{textcomp} \usepackage{xcolor} \usepackage{url} ...
1
vote
0answers
28 views

replacing macros parameters by its definition [duplicate]

Usually, I use many macros in my documents to save time. I am searching for clever "ideas, methods, tools" which can replace macros by its definition. For example, if we have a the following document ...
2
votes
1answer
58 views

Error: Command \ invalid in math mode

I am getting the following error: Command \ invalid in math mode. Why? Compilation ends but no PDF is created because of those errors. This seems to be the problematic piece of code but I don't ...
2
votes
1answer
27 views

defining macros in lyx

I am having a problem defining a script that I got as a macro in LyX (or even making it "work" in LyX). The script I have is the following: ...
6
votes
2answers
345 views

Changing fontsize within soul underline

This question is related to How to create a newcommand for fontsize?. I would like to change the fontsize within \ul of the soul package. For example: ...
17
votes
2answers
215 views

Can I turn a collection of optional parameters into a macro?

I currently have several environments from mdframed that have a large number of options that are shared between them. The situation looks like \newmdtheoremenv[options0,options1]{env1}{Environment 1} ...
5
votes
1answer
237 views

Automatic LaTeX parsing to replace text with macros

I know this title is pretty bad but I couldnt come up with something better. Basically what I want is to be able to write normal text, but that it displays in PDF in a custom alphabet once compiled. ...
1
vote
0answers
17 views

Can I use Writer2LaTeX and the `mla-paper` style together?

I use LibreOffice 4.1.3.x, and have had success using a patched version of Writer2LaTex with documents created in LibreOffice Writer. I want to create a (sub?)filter for Writer2LaTeX that allows me ...
4
votes
1answer
104 views

tikz def node name (or reference) for nodes create using the def

I have the following definition in order to create a node with cylinder shape \def\dnc[#1,#2,#3,#4]#5{ \node[draw, cylinder, alias=cyl, shape border rotate=90, aspect=1.6, % minimum height=25, ...
2
votes
2answers
114 views

Why can't I renew the \label command in math mode?

When I'm writing a paper and want to refer to a section, figure or equation in a different part of the document, I end up spending a lot of time scrolling through my source code so that I can see what ...
0
votes
1answer
53 views

Cite Command with a Customised Field for Biblatex

I am writing a PhD and my mentor wants me to use a specific short form of citation in the footnotes and long one in the bibliography at the end of the work. So basically I need to have three short ...
2
votes
1answer
68 views

Hacking into (internal) references in exam class

So far, I have used my homebrewn style file to create the examination papers which have multiple sets of questions. Recently, I switched to the exam class and immensely enjoying the additional power ...
5
votes
1answer
266 views

Putting normal letters in between Greek ones

So I am trying to write out Gauss' law for gravitation and I am having a hard time figuring out how to write it out without an error. I am currently trying to write in an equation block ...
6
votes
1answer
53 views

Conditional based on character following the macro

Basically, I would like to something like \xspace does, i.e. the meaning of the macro should depend on what is following it. So for example if I say \mymacro a it might expand to foo, and if any ...
1
vote
1answer
42 views

Why doesn't TeXstudio produce {} for my custom commands?

I'm having the following problem in TeXstudio 2.7.0. I have a template where I've declared some custom commands, such as \newcommand{\myAnswer}[1]{ \begin{itemize}[leftmargin=*] ...
6
votes
1answer
87 views

Why \shorthandon and \shorthandoff cannot be embedded in other macros?

Surrounding \title macro with \shorthandon{;:!?} and \shorthandoff{;:!?} gives the expected result with babel's french language (space added before the '?', '!', ':' and ';'): ...
3
votes
1answer
24 views

bibtex ignores MACROs in bst style

So I created my custom bst file using "latex makebst" it mostly works fine and I slowly get a rudimentary hang how the .bst thing works. Mostly thanks to this guide ...