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

2
votes
0answers
51 views

File .tex but content is LaTeX? [closed]

I'm reading the content of The TexBook then I realized the big difference between LaTeX and TeX. The fact is that LaTeX pre-programs huge things, like sections, titles, paragraphs, so the user does ...
2
votes
4answers
94 views

Define variables holding a percentage

I would like to define some variables in a tex document. For example, I write in .tex something similar as: Our tool succeeds to validate x samples out of all the y samples, thus its success ratio is ...
15
votes
5answers
600 views

command for floor

I need something that corresponds to floor() to use it in a macro (I don't mean the notation, I really mean the function that rounds downwards). Something like this: \floor{34.75} produces 34 ...
3
votes
2answers
45 views

How to run \IfSubStr on a macro parameter that may contain a newline

I have a macro where parameters may contain newlines but when one does, everything seems to break. How can I prevent this problem? I also want \IfSubStr to look for a match anywhere in the ...
3
votes
1answer
50 views

Change `\overline` command with `\uc`

I'm trying to change \overline command with \uc completely. But pdflatex is giving error below: ! TeX capacity exceeded The code: \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} ...
2
votes
2answers
89 views

Read part and page count from auxiliary file

My main document is included into another that rearranges and adds crop marks to it. For universalizing my script I need to extract the page and part count out of the .toc- or .aux-file. These are ...
1
vote
1answer
111 views

Automated Cover Letters with Dynamic Content [duplicate]

I'm trying to generate cover letters starting from a single document. Since I'm sending the same letter to different persons with different address I thought it would be great to use this document as ...
2
votes
1answer
28 views

Macro defining another macro with spaces in its name

I am trying to use the KOMA-Script command \newcaptionname which takes a macro name as its second argument, but I need spaces in it: \documentclass{scrartcl} ...
3
votes
1answer
142 views

Define numeric variables

I would like to define some variables in a tex document. For example, I write in .tex something similar as: Our tool succeeds to validate x samples by Method A, and y samples by Method B. Thus its ...
1
vote
1answer
41 views

Troubles with \centerline for center a line of text in a two column document

I'm composing a two column document with the scrartclclass. I need to emphasize few sentences along the text with an special typographic highlight. I was trying with the \centerlinecommand but it ...
0
votes
1answer
49 views

Strange behaviour of ifnumequal?

If I use \cfoot to evaluate and print this section counter, it shows the correct section number in my appendix. However, when I evaluate the section counter using \ifnumequal, it shows that the ...
4
votes
1answer
110 views

How to redefine a command using \DeclareMathOperator

I'd like to declare some new operators using \DeclareMathOperator and some of the names are already taken by other commands (that I do not want to use). Is there an equivalent to the \renewcommand ...
2
votes
1answer
67 views

Height of a tabular cell & bounding boxes

Is it possible to calculate the height of a tabular cell to be reused as a value for vertical offset of the bounding box, similarly to how Hy@raisedlink takes you one line above of where the actual ...
7
votes
2answers
179 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
313 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
90 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
58 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
96 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
113 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
466 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
215 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
251 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
246 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
47 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
80 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
191 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
42 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
135 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
109 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
65 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
72 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
75 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
283 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
102 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 ...
7
votes
1answer
96 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
38 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
49 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
205 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
43 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
326 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
123 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
73 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
254 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
44 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
109 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
137 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} ...