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

7
votes
2answers
154 views

How can I draw an arrowhead only at the end of a path drawn with \foreach?

I want to define a command for drawing some special polygonal lines with pgf/tikz. In these polygonal lines, the line styles are of alternating change. The following is my latex code: ...
9
votes
1answer
307 views

Macro to automatically save section name of previous section and next section

EDIT: I've edited the code that reproduces the anomalies, but I'll work on the code to more accurately depict the problem later on the day. Weird spacing in index Index doesn't appear in footlinks / ...
2
votes
1answer
77 views

Slanted grids in TikZ as a macro?

I'm trying to draw a diagram with slanted grids in it, sort of like the 3D effect given at http://www.texample.net/tikz/examples/3d-graph-model/ Ideally, I'd like a macro slantedgrid so that for ...
0
votes
2answers
53 views

newcommand with variable number of arguments

I have seen several related questions, but none seems to address specifically this. I would like to define a command that accepts a variable number of arguments. Something like ...
2
votes
0answers
81 views

fancyvrb inline verbatim with \newcommand and \CustomVerbatimCommand

I've just registered. This is my first question to this site. I am trying to make a verbatim command for inline code. This has been asked and answered many times before, but I never found a direct ...
4
votes
1answer
106 views

Check for first occurrence of element in chapter

I'm writing a text containing several chapters. In addition, I use about 50 acronyms. Now I would like to expand the acronym in each chapter, but only at its first occurrence. For this, I'm thinking ...
8
votes
3answers
439 views

Determine last day of given month

I want to determine how many days there are in a particular month. Using the datenumber package, I thought I could simply set the date to the 1st of the next month and then back up one day would be ...
2
votes
1answer
158 views

Copy to clipboard using Javascript macro

I'm pretty inexperienced with Javascript, especially within LaTeX, so I'd like some pointers, guidance or even an MWE of my proposed "button": I want to create a button to copy data to the system ...
5
votes
0answers
237 views

Copy to clipboard feature in PDF output

I want a clickable copy to clipboard feature in my PDF document. Ideally the macro also allows for graphical elements to be embedded inside them (say, a button that will automatically copy paste ...
2
votes
1answer
39 views

command to print indexed constants [duplicate]

I am writing a maths paper where I have a lot of constants. I am indexing them to differenciate them. Basically my text looks like blabla $c_1$ blablabla $c_2$ blabla $c_3$ blabla $c_1$ blabla ...
8
votes
2answers
241 views

Use a character other than the backslash for commands

I happen to author LaTeX code in an environment that makes entering the backslash tedious¹. Can I somehow tell LaTeX: From now on, treat, | (or another rarely used character) as if it were a \, so ...
7
votes
1answer
45 views

Automatically generate new commands with symbol names

As an extension of my earlier question Automatically generate new commands, I want to generate commands for Greek random variables as well, that is: \usepackage{bm} \newcommand{\myrv}[1]{\bm{#1}} ...
3
votes
1answer
65 views

Sectionname of section at top of page in footer

When fancyhdr prints the header and footer, I believe it uses the following order: Print header Print page Print footer The problem with this order is that when you have a section in the middle of ...
0
votes
0answers
20 views

Begin a text at a certain distance from the margin after an hyphenation

I ave a command to include a title and to begin my fake environment, fake in the sense that it is not called by a \begin{myenv}, the problem is that the long titles do break on the second line, but it ...
11
votes
3answers
185 views

Easy command or package for properly formatted integrals?

I like to format my integrals so that there is less space between the integral sign and the integrand, more space between the integrand and differential, and so that the differential is upright. ...
4
votes
1answer
39 views

\hspace error missing number treated as zero

I have two tabular environments. To redefine the space between them, I used \hspace in the following ways: \hspace[*][1cm] \hspace[1cm] Both the commands complain the same error, Missing number, ...
0
votes
0answers
45 views

defining a command

how can I define a command so that in the preamble of my document I can have something like \FigureFolder{name} So that the following two commands will work ...
6
votes
5answers
131 views

newcommand with optional superscript

In my thesis i need to use quite often the partial differential fraction like \frac{\partial^\alpha x}{\partial y^\alpha }} I therefore defined the command ...
3
votes
2answers
100 views

Automating extracting values from existing commands

(Part 1) I'm trying to extract values or parameters from a predefined command to use in another command. Is this possible? I'll add an example to clarify: \fancypagestyle{c.appendix.sep}{ ...
6
votes
1answer
62 views

Is it possible to know the actual length of a rubber length

The MWE is A \hskip 0pt plus 2pt \foo B \end Then macro \foo will tell me the actual length of the previous \hskip in the log file. Is it possible to write such macro \foo? How?
4
votes
1answer
68 views

How to make a section without margin with the command “\exersize” like this:

‎ \documentclass[12pt‎ , ‎a4paper]{report}‎ \usepackage[framemethod=TikZ]{mdframed} \usepackage{xcolor}‎ \usepackage{titlesec}‎‎ ...
9
votes
1answer
74 views

Create a switch from a given macro

I would like to create the equivalent of what \bfseries is for \textbf, relative to the command \shadowtext, which is defined as: \newcommand\shadowtext[1]% {% \begingroup% ...
10
votes
2answers
280 views

Defining a new command name in the correct way

I'd like to define a short command name \gm{a,b} that would mean in LaTeX \overset{a\to b}\longrightarrow I tried on my own. The below code only works for \gm{a} (or \gm{b} if changing a into b) ...
8
votes
2answers
99 views

Apply command to list of elements separated by \and

I am trying to build a command similar to the \author command. It takes one argument with is actually a list of arguments separated by \and. The command needs to apply another command like \underline ...
6
votes
1answer
91 views

Splitting a CSV list from a xkeyval key argument into parts

Is it possible to store the key value argument (a cvs list) to a macro (via \def) and split/further process the content of that macro with \forcsvlist command from etoolbox package? I want to ...
1
vote
1answer
35 views

Macros with \fi for showing and hiding proofs [duplicate]

I would like to be able to globally showing and hiding proofs on a document, and be able to use macros to open and close the proof environments. Here is my current MWE: \documentclass{article} ...
7
votes
1answer
48 views

Label handling in a macro

I want to create an environment to easily list a bunch of subfigures with their explanations. But the explanations should appear only in the caption of the complete figure, instead of the subfigure's ...
7
votes
3answers
201 views

Automatically generate new commands

In order to separate the content structure from the style, I decided to implement commands for denoting random variables: \newcommand{\myrv}[1]{\mathbf{#1}} \newcommand{\rvA}{\myrv{A}} ...
5
votes
1answer
42 views

How to include files from a directory specified by a concatenation of text and a macro?

This is almost certainly a silly mistake somewhere. I'm essentially trying to do what is being done here. My MWE project: $ find ./ ./ ./common ./common/preambleCommon.tex ./mydoc ./mydoc/mydoc.tex ...
19
votes
2answers
317 views

I want to start learning how to use \newcommand \newenvironment and \def any suggestions where to start?

I have been using LaTeX for a long time now, and I find myself often going to this website to solve my problems. This often includes copy pasting codes which include \newcommand, \newenvironment and ...
4
votes
1answer
106 views

How can I define a custom tcolorbox environment with color as a parameter?

I want to use different colored tcolorboxes. Is there an easy way to avoid all that typing for every single box by using \newcommand or a macro? \begin{tcolorbox}[ colframe=blue!25, colback=blue!10, ...
4
votes
1answer
72 views

Convert a latex command with parameter into a two begin end commands without parameter

I have defined a command \newcommand{\CV}[1]{\parbox[c]{0.2\textwidth}{\begin{flushleft}#1\end{flushleft}}} which I obviously have to call like \CV{My text} However I rather would like to use ...
11
votes
2answers
225 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
42 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 ...
5
votes
1answer
101 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
130 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
77 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} ...
7
votes
1answer
88 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} ...
8
votes
2answers
167 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}\\% ...
0
votes
0answers
46 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 graphics (\graphicspath{{figures/}}‎‎).
2
votes
1answer
90 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} ...
22
votes
1answer
640 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
102 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 ...
3
votes
2answers
68 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
65 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
41 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
70 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
38 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
60 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
159 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. ...