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

0
votes
0answers
16 views

Macro spacing mystery [duplicate]

I get different spacing results when I define a \hspace directly or as a macro. Directly: \documentclass{article} \title{Title} \author{Daniel Domingues \hspace{0.2cm}$\diamond$\hspace{0.2cm} ...
2
votes
0answers
24 views

How to pass an argument as a new command's name? [duplicate]

\documentclass{article} \newcommand*{\DefineRealCommand}[1] { {The real command name is: #1} \newcommand*{\#1}{I am the real command.} } \DefineRealCommand{HelloCommand} \begin{document} ...
5
votes
0answers
34 views

\xpatchcmd defines macros when applied to undefined commands

I stumbled over this feature (it's part of a bigger question, but I splitted it into two questions): Say, that we want to use \xpatchcmd (from xpatch) or \patchcmd (from etoolbox) and apply those ...
3
votes
2answers
107 views

LaTeX “Variables” - \@varname

I'm currently in the process of writing my first document class file (a personalized resume class), and I want to get a better understanding of what exactly I'm doing. So, right now I'm setting up ...
4
votes
1answer
20 views

mhchem macro in subscript

Consider the following MWE \documentclass{article} \usepackage[version=3]{mhchem} \begin{document} \begin{equation*} % c_\ce{CO2} not working c_{\ce{CO2}} \quad c_\text{working} \end{equation*} ...
4
votes
2answers
99 views

Need a Macro for Tables - independent of row and column size

I have created the following macro for Table: \newcommand{\createtable}[7]{ \begin{table}[htbp] \begin{tabular}{|p{8cm}||p{8cm}|} \hline \begin{center}\textbf{\cellcolor{Orchid!25}{#1}}\end{center} ...
1
vote
0answers
24 views

Failure After Using Latexdiff Script: \begin{description} … ended by \end{document}

After running a script to use latexdiff on a multiple input latex file I am left with a diff.tex file that is generating the following error: ./diff.tex:7009: LaTeX Error: \begin{description} on ...
5
votes
1answer
41 views

Nested \newcommand for creating maps

I want to create a simple map using \newcommand. My \NewMapItem command defines another command which returns item's value. \MapItem simply replaces to that command. \documentclass{article} ...
0
votes
0answers
30 views

How to create a command with \section in it and using hyperref? [on hold]

So what I am looking for is a \newcommand that doesn't return a Warning. This is what I got so far: \documentclass[11pt]{article} \usepackage{hyperref} \newcommand{\sDef}[1]{\subsubsection{Definition ...
6
votes
2answers
69 views

New Command For Inline Code

I am using the listings package to enter large blocks of code into my document, however I am trying to write a custom command that uses my current settings to do inline code. For example I want to be ...
2
votes
1answer
28 views

Text in custom command overflows the page

This text is connected to solution described in this question: How to user bold in custom command? When I use this custom command: \newcommand*{\myfont}{\fontfamily{pcr}\bfseries} ...
4
votes
2answers
64 views

Unicode macros for square root and integral

Is it possible to define math-mode macros √ and ∫ which would expand in the following way: √a ≡ \sqrt{a} √{a + b} ≡ \sqrt{a + b} ∫ ≡ \int ∫_a ≡ \int\limits_a ∫^a ≡ \int\limits^a ∫_a^b ...
5
votes
1answer
36 views

TexStudio: Enable spellchecking in user-defined commands

I am trying to find a way to enable spell-check in cases such as: \remark[I don't understend this]{$2+5=7$} I found something that might look as an answer but it sadly does not work ... In ...
1
vote
2answers
61 views

Getting an error when defining a macro in a TiKZ picture

I like a certain style of vertices in my TikZ drawings so I want to define a macro to save time formatting. It has two arguments, one names the node, the next is its location. It should have a blank ...
1
vote
1answer
78 views

Command already defined (custom command)

When compiling following code, I the compiler tells me that a command is already defined (the name is \c@b...). \documentclass{article} \usepackage{calc} \usepackage{ifthen} \usepackage{tikz} ...
5
votes
2answers
79 views

Use \foreach loop to execute macro with parameters of macro provided in a list

I have to execute a macro a number of times, and would like to provide a list of the parameters to be executed. So, instead of \FormatLinks*[Main Search Site]{Google}{http://www.google.com} ...
5
votes
1answer
57 views

trigonometric function inside newcommand

I want to know if there is a way to define a variable that depends on a trigonometric function, like this. \newcommand{\cosTheta}{cos(30)} Such that it is parsed before using it in a tikz segment, ...
7
votes
1answer
35 views

TeX quotation marks short-circuit optional argument with \ifx

In a command with an optional argument, if I put a string beginning with TeX quotes (e.g., ``quote'') in the optional argument, something goes wrong. See the bottom entry in the example below. The ...
0
votes
0answers
22 views

What does the @ symbol sign do in Latex? [duplicate]

The document class my Uni provides has a bunch of lines that appear to define macros with "@" in the name, like this: \newcommand{\uni@title}{} \renewcommand{\title}[1]{\renewcommand{\uni@title}{#1}} ...
9
votes
1answer
93 views

Forcing macro expansion

I have done my best to understand \expandafter, \edef and friends, but I can't find a way of using them to force expansion of the parameter passed in to the macro \FormatDate in the following example. ...
2
votes
1answer
17 views

\NG package conflict

I have a package conflict resulting from a custom command in an .sty file I am using. The command looks like this: `\newcommand\NG[1]{Gram.: {#1}}%Note Grammar Now, if I run pdflatex it gives me ...
7
votes
1answer
338 views

How can latex help me format and present lots of data in a report?

At work I am responsible for creating information security reports that contain long narratives and reference what we refer to as "vulnerabilities". These vulnerabilities are presented in a table. I ...
1
vote
2answers
77 views

Automatically suggest arguments for user defined commands

When using the command \ref{ it automatically suggests several arguments, such as eqn:equation1, fig:figure1, and so on. I have defined the command \newcommand{\fref}[1]{Fig. \ref{#1}}, which rather ...
2
votes
1answer
47 views

How to user bold in custom command?

I would like to highlight some text in my paper as "programming code" with Courier font family and I found this solution. \newcommand*{\myfont}{\fontfamily{pcr}\selectfont} ...
7
votes
1answer
77 views

Why \begin{flushleft}…\end{flushleft} doesn't behave as \flushleft…\endflushleft?

The following MWE points out that \begin{flushleft}...\end{flushleft} doesn't behave as its macros counterpart: \flushleft...\endflushleft: flushleft environment's effect stops after ...
3
votes
1answer
100 views

How to have text inside round brackets on a line and also be added to a second index with predefined index search keys?

I've written a text with 200 quotes. One quote example: "Und wir haben die Liebe erkannt und geglaubt, die Gott zu uns hat. Gott ist Liebe, und wer in der Liebe bleibt, der bleibt in Gott und Gott in ...
3
votes
2answers
129 views

How to tie TeX macros to text or another macro?

Is it possible to tie a TeX macro to some text (e.g. the next paragraph) or another macro? For your information, here is a more specific description of the problem: I am using a set-up macro ...
2
votes
0answers
46 views

Argumentless macros for use in other macros

I'm in need of argument text formatters for use in some environments that use macros to redefine properties (e.g., enumitem). I need to underline text but there is no equivalent argumentless macro ...
2
votes
1answer
18 views

All Environments Share Numbering (According to Subsection)

The numbering scheme I'm looking for causes every environment to share one common numbering counter, according to subsection. For example, in my notes the numbering would look something like this: 1 ...
2
votes
1answer
51 views

LaTeX command or environment to selectively print one out of several given options

I'm currently wasting my time by trying to create a proof-of-concept class to show that writing our university's curricula with LaTeX instead of MS Word would have some benefits. Since these curricula ...
2
votes
1answer
20 views

Hide titleformat in a macro when [explicit] is loaded

This is a follow-up question to: Different titleformat style for different numberless chapters I have something like the following macro: \titleformat{\chapter} {\normalfont\Huge\color{blue}} {} ...
3
votes
1answer
67 views

Multiple Choice Answer Key in exam package at the end of document

I think this is a follow up question to: Print answer key to multiple choice questions I am trying to create an answer key at the end of my exam class document where all the questions are multiple ...
4
votes
1answer
56 views

Tagging latex code for subsequent aggregation

I'd like to tag portions of LaTeX markup throughout my document. At some point later, I'd like to replicate all of the tagged portions. As an example of my desired behavior: \begin{itemize} ...
5
votes
1answer
49 views

Two parenthesis and a slash all the same size and slightly bigger than the expression contained

I'd like to define a command for the red part in the following expressions: generated by the following code: f(x/y) \qquad f\big( g(x)\big/y\big) \qquad f\Big(h\big(g(x)\big)\Big/y\Big) \qquad ...
0
votes
0answers
62 views

Is there a good way to automatically generate a list of commands/environments defined in the preamble?

Background I have seen beautiful manuals with commands and descriptions of what they do. I have a shared preamble (edited by multiple people and used for multiple documents) that has a multitude of ...
6
votes
1answer
80 views

Why does the ragged2e package screw up my emphasized text and headings?

I encountered a weird behavior of the ragged2e package. \documentclass{article} \usepackage{blindtext} \usepackage{amsmath} \usepackage{ragged2e} \newcommand{\ir}[1]{_{\mathrm{#1}}} ...
3
votes
3answers
45 views

Macro not Working in Itemize-Block

I want to write an estimation of effort for one of out clients. The client wants a few changes so I am estimating the required time for every change. I could sum up the efforts manually but that ...
7
votes
1answer
38 views

How to create custom labels which can be referenced?

I would like to label the hypotheses in my thesis similar to equations (e.g., the first hypothesis in chapter 3 should be “H-3.1”). Also similar to equations, I would like to reference these ...
5
votes
3answers
250 views

Is \renewcommand{\fi} possible?

I am writing my own command and i would like to define for each letter : \newcommand{\fletter}{\mathfrak{letter}} but i can't do it for the letter i even with \renewcommand. Is it possible to ...
3
votes
1answer
62 views

Custom “list of” command for lab notebook

I'm keeping my lab notebook for my PhD in LaTeX. I have it set up such that each "project" has its own chapter. When I make a new entry into the notebook I use a custom "entry command": ...
7
votes
1answer
83 views

Suspending environments and resuming by another environment

Is it possible to interrupt a LaTeX environment, say OuterEnv, by another environment, say InnerEnv, the later closing the first in the environment startup code, doing 'whatever' and then resuming the ...
1
vote
1answer
23 views

Custom linespacing in an parbox

Is there a way to set the line spacing into a \parbox? What I am trying to do is create a new command from a \rotatebox and \parbox and assign locally, i. e. only inside of the \parbox, custom line ...
5
votes
2answers
69 views

Empty parameter in xdef definition

Considering this definition of a latex macro: \newcommand\createCMDMANUV[4]{% \expandafter\@ifdefinable\csname #3#2\endcsname{% \expandafter\xdef\csname #3#2\endcsname##1{% ...
0
votes
0answers
36 views

Tikz: Using the size of one node to set the size of another node [duplicate]

I've been working on making diagrams involving many connected components, that will look something like the following: I want to be able to make such diagrams in a reasonably modular fashion, ...
7
votes
1answer
37 views

Patching/Preventing effective code in a package

Consider a command being defined in a package (or used from another package), say \somethingstupid and being used before \endinput within the package, doing some non-typesetting setup (coloring, ...
8
votes
5answers
312 views

A more elegant version of the \ifnot macro

A TUGboat article of 15 years ago mentions an \ifnot macro by David Kastrup whose implementation is: \def\ifnot#1{#1\else \expandafter\expandafter\fi \iffalse\iftrue\fi} However, this macro ...
0
votes
0answers
15 views

Problem using \newcommand for entering code snippets [duplicate]

I'm writing a report which I need to post various code snippets in. I decided this is how I wanted to put each bit of code in: \noindent \begin{minipage}{\linewidth} \begin{lstlisting} Code goes here ...
0
votes
2answers
29 views

pderiv square macro [duplicate]

How do I update the macro for partial derivative in order to accept standard second or bigger order? I have so far \newcommand{\pderiv}[2]{\frac{\partial #1}{\partial #2}} for the first order ...
5
votes
1answer
46 views

Automatically change font size in main text and footnote

I am typesetting an article with a lot of quotes from poems, and I have defined a command that puts the poem information at the end of the line \newcommand\poemcite[1]{\hfill{\small #1}} But if I ...
14
votes
2answers
220 views

How can own commands be aware of \global?

When I define a command that defines commands \def\makefoobar{ \def\foo{foo} \def\bar{bar} } and prefix it with \global { \global\makefoobar } it is treated like { \global\def\foo{foo} ...