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

6
votes
1answer
81 views

Error using \newcommand within a beamer frame

For some reason my beamer presentation does not compile when \newcommand is placed inside the frame environment. Here is a minimal working example: \documentclass{beamer} \begin{document} ...
5
votes
2answers
85 views

newcommand multiple default values

I'm busy with a document that change frequently. and special the used dimensions change. This result in a large chance that i miss a value when i change the dimensions. To tackle this problem i made a ...
2
votes
0answers
61 views

Counter of arguments and ifnum [closed]

Why is this ifnum always true? \@tempcntb is 5, shouldn't it instead print \tmp for the last argument? Also, I don't understand what m@ne does, because this certainly doesn't advance the counter by 1 ...
5
votes
1answer
77 views

TikZ programming/macros, \list construct

TikZ 3.0 manual, on page 83, we have (not complete code): \list{--}{\topsep=2pt\itemsep=0pt\parsep=0pt \parskip=0pt\labelwidth=8pt\leftmargin=8pt \itemindent=0pt\labelsep=2pt} #5 ...
9
votes
3answers
248 views

Macro evaluating number of arguments without limitation

Is it possible to have a macro like this one: \documentclass{article} \usepackage{xparse} \pagestyle{empty} \ExplSyntaxOn \NewDocumentCommand{\HowManyArguments}{ oooooooo } { \IfNoValueTF ...
1
vote
0answers
52 views

How to create a TeX command for tower functions? [duplicate]

Could you please explain how to define a command \tower{<1>}{<2>}, whose first argument is to be the basis (and the exponent) while the second the number of its repetitions in successive ...
1
vote
1answer
124 views

naming argument and optional-argument for \def, \newcommand and newenvironment

I know how to create a new command or an environment. I think it will much better if I can specify name of the arguments. For example in framebox command and array environment below, we know exactly ...
2
votes
1answer
81 views

Using SageTeX with siunitx

I have the following problem: I'd like to do calculations using SageTeX and use the result in an siunitx expression, so that (for example) \SI{\sage{3.5^2}}{kg m} would give me the same result as ...
1
vote
1answer
75 views

Bold and Italic texts styles are too big

I have a problem with my \textbf and \textit commands, it makes my texts bigger than when no styles are applied. An example is shown here: I also put an URL inside the bold command ...
2
votes
0answers
56 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
103 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
611 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
50 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
59 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
98 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
130 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
36 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} ...
4
votes
1answer
661 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
42 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
59 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
159 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
76 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
213 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
322 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
100 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
68 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
114 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
121 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
484 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
274 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
277 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
45 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
251 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
49 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
91 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
22 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
200 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
58 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
47 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
146 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
112 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
88 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
78 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
291 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) ...
9
votes
4answers
165 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
106 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
41 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
52 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
209 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}} ...