{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
1answer
53 views

Avoid brackets with a command having an optional argument as subscript

I have the following code: \documentclass{article} \newcommand{\quot}[3][c]{\frac{#2}{#3#1}} \begin{document} \LARGE $A_\frac{a}{bc}$ $A_{\quot{a}{b}}$ $A_{\quot[d]{a}{b}}$ \end{document} If I ...
6
votes
1answer
167 views

Drawback of using a using a new command instead of \begin{something}?

Is there a drawback of defining and using a \newcommand instead of \begin{something}. e.g. if I use \newcommand{btkz}{\begin{tikzpicture}} \newcommand{etkz}{\end{tikzpicture}} \btkz \node{Hello ...
3
votes
2answers
111 views

returning maths values in a new command

So I'm trying to construct a command which calls another command to make typing easier, but for some reason I'm not able to get the commands to return things properly. Here is what I have ...
8
votes
3answers
330 views

Macro to close all open environments, groups and argument delimiters

Initial Request I am in search for a macro that would close all curly brackets and all open environments. Ideally, I could write something of the following sort: ...
1
vote
2answers
122 views

How can I run pdflatex on multiple .tex files on Windows 7?

I built some graphics with TikZ and pgfplots. I have put the code with the most minimal necessary preamble into a standalone document for each figure. Say I put all those files for chapter 3 (hence ...
6
votes
1answer
43 views

arithmetic expression involving command

Simple question. I would like to do this: \newcommand{\scatterplotwidth}{0.5\linewidth} .... \includegraphics[width=0.9\scatterplotwidth]{myfig} Without the 0.9 it works. Is there a way to have ...
6
votes
1answer
97 views

Different result using \newcommand and \NewDocumentCommand

I am writing a text which references a whole bunch of Brazilian norms. All of these norms are prefixed with "NBR". I therefore created the following command \newcommand*{\NBR}[1]{NBR #1\cite{NBR#1}} ...
7
votes
2answers
215 views

Associate counters — stepping (many) counters simultaneously

This is (perhaps) not a real question and there maybe already an answer to my proposition/request. The situation There are packages that provide the number of the last page (i.e. lastpage or the ...
0
votes
0answers
23 views

Nested definitions [duplicate]

I have the impression that if one defines a macro inside the definition of another one, then #1 and so on indicate the outer macro's arguments, while ##1 indicates those of the inner one. Is that ...
10
votes
2answers
229 views

Can I define a command with optional argument coming after the mandatory ones?

Is it possible to define new commands having the following form: \command{<marg>}[<oarg>] I have seen commands of this form in the fontspec package. But not sure how to achieve this.
4
votes
1answer
67 views

mtpro2: PARENS environment error

\documentclass[10pt,a4paper]{book} \usepackage[utf8x]{inputenc} \usepackage{ucs} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage[lite]{mtpro2} ...
15
votes
1answer
437 views

What does \@car do?

The title says it all. I'd like to know what \@car does. I came across it reading through the source of the hyperref package, but it doesn't seem it's defined as part of the package. I tried Google, ...
7
votes
2answers
159 views

Delimited arguments and using a macro inside of itself

I wanted to play with delimiter sizing without using the \delimiterfactor, -shortfall, etc. and made the following: \newdimen\bigdim \bigdim = 1.9743ex \newdimen\Bigdim \Bigdim = 2.671ex ...
18
votes
1answer
270 views

Is it possible to define a command taking an optional star and working in a subscript?

Note: this is more or less a cross-post from my blog. I hope this is acceptable, especially that this is a genuine question! I’m currently writing a (longish) document on mathematics. Among other ...
3
votes
2answers
71 views

How do I output “dumb” apostrophes with the sffms package?

I'm using the sffms package to typeset a book manuscript (using the version of the package shipped with TexLive 2013 on a Mac). I want to output both double and single quotes so they are "dumb" or ...
3
votes
0answers
49 views

A mysterious blank line come from an \hskip?

I use a very complicated .sty file. The main purpose of this .sty is to enable a special inline box in which texts can be typeset in a very special way. There is no problem inside the box. The .sty ...
0
votes
0answers
37 views

Follow Up Question : multiple lines format for ifthen or ifbool compound statements

Follow up question to How do I add multiple macro definition inside an \ifbool compound statement? Ok if you look at the last post, people fixed my format for the ifthen / ifbool statement format to ...
7
votes
2answers
267 views

Is there any analog to #pragma once in (La)TeX?

In C, I can write #pragma once as a preprocessor directive at the top of a header file, which tells any compiler that supports it to include the file a maximum of one time per compilation cycle, ...
5
votes
4answers
163 views

Alignment of the text like a table

What I wanted to achieve was this: I defined a new command like this: \newcommand{\details}[2]{ #1 \hspace{2cm} : #2 \\ } The full MWE is as follows: \documentclass[12pt]{article} ...
3
votes
1answer
120 views

How to Define New Todo Command Which Still Takes Options

I am using the package todonotes in order to handle my TODOs. As written in the manual, one can define a custom TODO command like that: \newcommand{\feedbackRequired}[1]{\todo[color=red!70]{#1}} ...
15
votes
3answers
416 views

Macros that know their macronames themselves?

Some programming or scripting languages know the feature of #0 or $0, holding the name of the current script or the current routine. Does a similar technique (or a workaround) exist for the macro ...
2
votes
0answers
31 views

\newcommand - Missing \begin{document} [duplicate]

On defining a new command, and using it, LaTeX throws an error that Missing \begin{document}. What is the issue here? \documentclass[12pt]{article} \newcommand{details}[2]{ #1 \hspace{2cm} : #2 } ...
1
vote
0answers
40 views

How do I make a new command with author/journal/year citation in footnote

\documentclass{beamer} \usepackage[backend=bibtex]{biblatex}%backend=biber, natbib=true, style=chem-acs \bibliography{oralspaper} \DeclareCiteCommand{\citejournal}%%%creating \citejournal command ...
7
votes
2answers
115 views

Redefine \newcommand to insert code at start and end of custom macros

I would like to be able to insert code into the definitions of my custom macros, without having to modify each macro definition. This seemed like a simple case of redefining \newcommand, but this ...
3
votes
2answers
70 views

How to expand a macro to use it inside a question in AMC?

Context I'm trying to use AMC to produce an exam with code in it. However, the use of verbatim code inside the questions is beyond the scope of the package. They suggest to declare boxes and used ...
5
votes
2answers
129 views

Use of \csname in \input produces mysterious results

I am stuck with the following one where I want to input a file with a name in the line of \jobnameQ.tex. Here is my MWE excerpted from a bigger picture. \documentclass{article} \usepackage{lipsum} ...
1
vote
0answers
74 views

newcommand, section

I just received a new task in LaTex with a predefined structure and predefined commands. There was also the command \mysection. I think it shouldn't show the text of the section in the document, but ...
2
votes
1answer
73 views

How to convert command parameters into optional ones?

LaTeX allows the use of optional parameters. Sometimes one wants to rewrite a command by making certain parameters optional: \newcommand{\foo}[2]{ #some commands } to: \newcommand{\foo}[2][a]{ ...
5
votes
2answers
84 views

Extra space in command created

Consider the following answer given by @egreg which can be found at http://tex.stackexchange.com/a/111043/10898 Why is an extra 6.799999pt space created when you issue a command like ...
6
votes
2answers
114 views

Using \mathpalette with macros that take more arguments

As I understand it, \mathpalette takes two arguments; the first must be a macro A that itself takes two arguments. A will be passed as #1 commands to reproduce the math enviroment at the location ...
1
vote
1answer
65 views

Beamer renewcommand

I am doing a presentation using the beamer class and I want to declare a new command, which shortens the following thing: \textsuperscript{1} to \up{1} I did this while using scrartcl with ...
3
votes
1answer
70 views

conditional loop printing text and icon

I'm new in the Latex world. I'm writing a little guide and I've choose Latex, in particular Texmaker for writing it. I'm trying to do a loop for printing some instruction as File -> Save as -> Ok. ...
3
votes
1answer
94 views

AucTeX insert-environment C-c C-e (no label prompt)?

Does anybody know how to configure Emacs or Auctex such that when you insert an environment for example with C-c C-e equation RET? Avoid having to type RET for (Optional) What label? question? Or ...
0
votes
0answers
26 views

Manipulating the output of \footnote

This is in a way a generalization of my earlier question Footnotes (e.g. citations) in the footline of beamer frames? Generally, I would like to know which macros (La)Tex uses to process footnotes ...
1
vote
1answer
78 views

Custom citing command. Bibtex key as parameter to \newcommand

I'm new to LaTeX and I want to define an auxiliary command for citing. What I would like to achieve is a \newcommand or similar that takes a BibTeX parameter such as paper and produces the same output ...
3
votes
1answer
83 views

Redefining a command and special character

I am trying to redefine \v command (wedge above character) to do what \vec does in mathmode and preserve \v in a command called, say \hac. This code works perfect \documentclass{article} \let\hac\v% ...
3
votes
1answer
94 views

How can I redefine the chapter command to display additional text below the title?

I'm relatively inexperienced with Latex. I'm using the Memoir class and I've been trying to develop a custom chapter style based on Danie Els' BlueBox style (the source for this is given on page 46 of ...
8
votes
1answer
250 views

How to rename an existing command?

I would like to know if renaming a command is possible in LaTeX. For instance, could I change the \section by \sec ? I read that some people used something called "alias".
6
votes
1answer
121 views

testing parameter values with \ifx

Let's say that I would like to redefine \@seccntformat so that whenever the section counter is printed, it is prefixed by Section, but other counters should no be changed. Here is my failed attempt: ...
0
votes
0answers
16 views

Include SVG aligns/centers different when used with “newcommand”? [duplicate]

this is my first post in this forum, but i have been here a thousand times, enjoying the high-quality answers to often also good quality questions. So i try my best to also provide all needed ...
4
votes
1answer
47 views

How to know if page is empty

Looking for macro to know if the current page is empty , and opening new page if were not as well. Is there any idea to do that? example in this MWE \documentclass{article} \usepackage{tikz} ...
2
votes
1answer
57 views

macro to showcase newly defined macros

I have the following MWE which takes an argument and prints it verbatim. I have obtained the code from this answer. \documentclass{article} \makeatletter \newcommand{\myverb}{% \begingroup % ...
1
vote
0answers
25 views

Macro for textinput without any formatting [duplicate]

Is there a LaTeX macro that just compiles whatever I type into it? Something like \text or \textnormal. I want to display a LaTeX code inline without any formatting, but don't want to escape ...
2
votes
1answer
121 views

Modify the @tufte@margin@float environment to automatically align floats

The Tufte classes provide the @tufte@margin@float environment which is used for tables and figures, but its result it's not automatically aligned with the text. The \marginnote command provide a ...
0
votes
0answers
30 views

Output command arguments for spellchecking

I have a longer tex file which contains text in different languages. The languages are highlighted in different colors, e.g. {\color{blue} some text in french } {\color{red} some text in ...
2
votes
0answers
83 views

What is the meaning of \+ in doxygen-generated latex?

When compiling a software reference manual with doxygen and latex output, I get the following error: ! Undefined control sequence. l.2 ... Modular System for Shelves and Coasts (M\+ ...
4
votes
1answer
75 views

text inside tikz node which can skip to an other

I would like to put text in a mini page with fixed length inside a tikz node using \sbox , if the text skip a specified length (10cm) it will be saved in an other \sbox and used inside a tikz node ...
8
votes
2answers
93 views

Package csquotes does not seem to work within a mdframed box defined via a macro

If I define a macro which uses a mdframed box, this seems to disable csquotes (red box). But using mdframed directly (i.e., without defining it via a macro), then the csquotes package can do its job ...
8
votes
1answer
294 views

Does \Twoheadleftrightarrow exist? How to write my own?

I'm a LaTeX newbie. I am writing a document in which I need to have a two-headed bidirectional arrow. Two-headed like \twoheadleftarrow, bidirectional like \leftrightarrow. Is there any package that ...
10
votes
2answers
156 views

Passing command output as a parameter to the other command

I created some kind of switch statement with a help of \ifthenelse command. Now, I would like to pass its output to another command. In my example I want to colorize each sentence with a color ...