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

5
votes
3answers
224 views

Incomplete \ifx

I am trying to define a function Lettrine from the lettrine one. I did it here successfully, but I need to add an optional argument to be able to use more lettrine features like ante: ...
3
votes
2answers
100 views

Why does Latex output a quadruple instead of a triple?

To keep track of definitions in a paper, I've written two versions for some macros. One is just the macro, like \mymacro and the other is an unfolded version of the macro, which I usually call ...
6
votes
2answers
61 views

Custom date format

I am trying to create a fancy date format as shown below: The following is a MWE of what I have so far. For some reason or the other I can't seem to get the right height. ...
13
votes
5answers
610 views

a new command of the form ----------{TEX}----------

Is it possible to create a new command of the form ----------{TEX}----------? For instance, I would like to have something like \nc{TEX} which produces "TEX" in the middle of the line and the rest of ...
5
votes
5answers
177 views

new command with cases?

This has been answered here for text outputs with the use of \IfEqCase from the xstring package. But if I want to use the output as a value to set a parameter in a function, it fails. Here is my MWE: ...
6
votes
1answer
115 views

Merging \newcommand and \renewcommand

Is there a merged command \maybenewcommand that is either \newcommand or \renewcommand, depending on the situation: if the command is not yet defined, use \newcommand and use \renewcommand otherwise. ...
0
votes
0answers
28 views

biblatex. comfortable author citing

I'm at the end of writing a text, and I'm not very lucky about the way I had to handle author names so far. I'm using the solution from Citing author's full name in biblatex the first time it ...
5
votes
3answers
137 views

Defining abbreviation command

I want to make a command that I say for example: \newcommand{abbre}{...} \def\abbre{Modular Response} And \abbre should display MR. Thanks
1
vote
2answers
54 views

Applying a style globally (example in fancyhdr - across page styles)

Imagine I wanted to make all footers, pagestyles, etc. in bold. There's nothing like a \globalpagestyle or something, so my take on the problem was something like this: \documentclass{article} ...
4
votes
1answer
108 views

Best practices for multilingual open-source book?

I'm writing an open-source book in two languages (English and Russian) and there are volunteers who would like to help with translation to other languages. My first idea is simple: let there be ...
3
votes
0answers
66 views

looking for selective latex command replacement methods

I have a perl script for generating wordpress (or physicsforums or wikipedia) style latex markup from standalone latex files, but it has grown into a bit of a monstrosity and has also recently met ...
1
vote
1answer
39 views

Retrieve a table with a Macro

I would like to retrieve a table with a Command which is using an new environment including a table. So basically something like: \begin{measurtab}{Test 2110} \value{0.0}{0.0} \end{measuretab} ...
4
votes
3answers
80 views

using a macro to define the body of a tabular / & separator problem

I'd like to create a macro that can create and fill a multiline tabular with 4 entries per line from something like \bidding{3H,4S,5C,X,XX,-} where the number of entries is of course dynamic. I have ...
9
votes
2answers
310 views

Why does it matter when \AtBeginDocument is run?

As I understood the macro \AtBeginDocument, whatever it says will be run right after \begin{document}. In other words, it will follow whatever else there is in the preamble. But I've noticed that it ...
1
vote
2answers
265 views

Where to type command line to compile Latex on Ubuntu? [closed]

(Please forgive me if this question is so simple or looks stupid) I want to run Latex on Ubuntu. It is said that we use similar commands as those used in Windows OS, (e.g. pdflatex file.tex, ...) ...
2
votes
1answer
41 views

Usage of minted inside a new environment, inside IfFileExists

I want to conditionally load minted and define an environment, but after using IfFileExists I'm running into an error: FancyVerb Error: Extraneous input `resetoptions \setkeys ...
6
votes
3answers
129 views

Report all duplicate macro names defined by \newcommand

I have a shell script that produces a large list of macros in an external file in the form: \expandafter\newcommand\csname XX Name ABC\endcsname{some text ABC 1} \expandafter\newcommand\csname XX ...
13
votes
2answers
165 views

Why does this use of `\expandafter` not work?

I've written the following code: \newif\ifconsecutive \consecutivefalse \newcommand{\myfirst}[1]{#1\consecutivetrue\expandafter\consecutivefalse} \newcommand{\mysecond}[1]{\ifconsecutive ...
4
votes
3answers
183 views

How do I split large numbers into groups of five digits? [duplicate]

I need to split a number of 27 digits into groups of 5 digits. I already had a look at siunitx, telprint and numprint. But these just allow me to generate groups of two or three digits. Is there any ...
2
votes
1answer
36 views

Passing commands as environment-arguments

I'm trying to realize two versions of an environment numberedlist: if no argument is passed to it, it should begin the environment enumerate and pass default values as its argument, if one argument ...
4
votes
5answers
172 views

macros, category codes, how to pass stuff with cat codes inside?

The original question is below (it was a bad simplification of the problem I had and also before being edited, it also contained major syntax errors). The problem that originated the question is why ...
0
votes
0answers
32 views

\newcommand that behaves like a normal word [duplicate]

Is there any way to define a \newcommand that behaves like a normal word? I have a few names for Objects, that might change later. To keep my flexibility i use ...
2
votes
0answers
58 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 ...
2
votes
0answers
43 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
74 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
113 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 ...
2
votes
1answer
68 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
84 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
150 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
121 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
205 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
37 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
45 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 ...
6
votes
1answer
70 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
83 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
58 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
72 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
233 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
115 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
77 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
61 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
98 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
604 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
46 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
55 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
93 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
120 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
32 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} ...