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

8
votes
2answers
300 views

How to replace “E” by “\mathbb{E}” throughout out the article in LaTeX

I have a quick question about replacement in LaTeX. At first, I used capital E throughout my paper and now I really need to replace E by \mathbb{E}, somebody suggests that I can use Macros to achieve. ...
5
votes
3answers
122 views

\newcommand for tabular entries using keyval

I am trying to define a command for tabular entries using keyval. \documentclass{article} \usepackage{keyval} \makeatletter \define@key{tabularEntryKeys}{a}[\dots]{#1 & } ...
7
votes
2answers
162 views

How to decompose a number

I'd like to define a command (namely \myproduct) with two arguments so that when I call it as \myproduct{125}{497} for example, the result would be 3 new commands for each argument, like this: \ci=1 ...
7
votes
2answers
149 views

How to compare against a constant with ifx?

I am trying to test one char substrings (TeX or LaTeX): \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{fp,stringstrings} \newcommand*{\mytest}[1]{% ...
6
votes
2answers
116 views

Arguments to function not losing braces

This MWE is boiled down so much the usefulness of the code is lost. However, the code nevertheless still exhibits the problem I'm encountering. \documentclass{article} \usepackage{pgffor} ...
5
votes
1answer
51 views

Lstinline macro inside another environment

Why does the MWE below compile with errors only if I use ths \lstnewenvironment line? And how to define the verbatim macro inside an environment? I heard it's possible using plain TeX? ...
5
votes
3answers
145 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
98 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
54 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. ...
12
votes
5answers
599 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
151 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
105 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
25 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
121 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
48 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} ...
3
votes
1answer
73 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
57 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
75 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
173 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
97 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
30 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
118 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 ...
12
votes
2answers
157 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
121 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
32 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
163 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
46 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
27 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
69 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
110 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
55 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
74 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
142 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
112 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
182 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
36 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
40 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
60 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
77 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
52 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
63 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
222 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
50 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
96 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
63 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 ...
0
votes
0answers
32 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
48 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
89 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 ...