{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
105 views

Different colours for each argument and value in listings

This recent question (Print blue brackets in one language and black in another) made me come up with (up to) two more questions regarding the listings package: Is there an option similar to opstyle ...
3
votes
0answers
149 views

Duplicate Line command in TeXShop for Mac

I'm a quite new user of LaTeX and one thing I miss in TeXShop on mac is a "Duplicate Line"-command, espacially when writing mathematical derivations. It's my impression that it is possible to create a ...
4
votes
1answer
80 views

Print blue brackets in one language and black in another

In addition to that question i wonder if it is possible to have that settings for one language and default settings for another ? How to highlight operators and brackets in a C listing? ...
3
votes
1answer
144 views

Can I use a TeX primitive in a “before” and “after” macro? (and how?)

The Question Can I use a TeX primitive in a "before" and "after" macro? (and how?) There are two questions that I found useful and related to my question, which sent me in the right direction: how ...
4
votes
1answer
129 views

Writing text content as labels and refer to them with \nameref*

I stumbled this morning, when I tried to improve (a possible) solution answer I gave to some question. I try to write automatically generated labels (using a unique naming scheme with prefixes etc.) ...
3
votes
1answer
153 views

Set samples in tikzpicture from macro value

I'm trying to use set the amount of samples per tikzpicture globally: \documentclass{standalone} \usepackage{pgfplots} \pgfmathdeclarefunction{gauss}{2}{% ...
3
votes
3answers
188 views

ConTeXt: Prevent Reference Name Clashes in Floating Objects of Different Types

I find it very annoying that ConTeXt uses the same namespace for references of floating objects. In other words, if you give the same reference to a figure and a table, then you'd always refer to the ...
6
votes
2answers
154 views

Where can I get a list of macros beginning with \var

I use macros like \varphi or \vartheta quite often, and I've recently discovered, there is also a \varnothing which is a bit like the \emptyset. My question is: How or where can I get a list of ...
7
votes
2answers
441 views

Shortcut to writing out long, common, expressions?

I'm writing an astronomy paper and have some symbols and variables which are common throughout. It's becoming cumbersome to write them out each time. Is there a way to create a shortcut of sorts for ...
2
votes
1answer
45 views

Make macro obey spacing or lack thereof

I made this simple macro: \documentclass{ltxdoc} \newcommand\Q{\textbf{Q}} \begin{document} I like to type my \Q's in bold quickly, but sometimes I also end my line with \Q. This doesn't have it's ...
3
votes
1answer
54 views

array of organizations with a default?

I am trying to make a custom list, that has a default value, without being dependent on too many other packages because I am trying to get some very specific formatting. I am trying to use this for a ...
8
votes
1answer
353 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
199 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
135 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 ...
6
votes
1answer
200 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 ...
10
votes
3answers
283 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
55 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
295 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 ...
3
votes
1answer
214 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
141 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
65 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
152 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
712 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
106 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
103 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
193 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
224 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
68 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} ...
7
votes
1answer
7k 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
50 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
101 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 ...
14
votes
1answer
2k 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
127 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
386 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: ...
10
votes
1answer
378 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
190 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
114 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
272 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
136 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 ...
9
votes
3answers
606 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
469 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 ...
11
votes
0answers
549 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
69 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 ...
9
votes
2answers
293 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
66 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
121 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
33 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
268 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
174 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, ...
1
vote
0answers
61 views

Defining a standard folder for image resources [duplicate]

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 ...