{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
24 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}} ...
10
votes
1answer
105 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
33 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
371 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
96 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
52 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
130 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
112 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
143 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 ...
3
votes
1answer
77 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
24 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
86 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
34 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
202 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
65 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
61 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
69 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
119 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
52 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
51 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
299 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
74 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": ...
8
votes
1answer
93 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
34 views

Custom linespacing in a 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
156 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{% ...
7
votes
1answer
42 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
350 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
16 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
41 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
98 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
231 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} ...
0
votes
1answer
92 views

Command for \part style output and little abstract

I am new in this forum and I am kind of novice in LaTeX. I would like to know how to make this presentation as macro in order to change the PART (here chapter, I am using \documentclass{article}) ...
10
votes
1answer
177 views

Why does \def@#1\space not work?

The code \documentclass{article} \begin{document} \begingroup \catcode`@\active \def@#1\par{<#1>} @some text \endgroup \end{document} works flawlessly. Why not so when I replace it by the ...
4
votes
1answer
36 views

newcommand with optional argument displays wrong text

I tried to set up a new command with optional arguments. The problem is that the command displays 'st:code'. What's wrong? Thanks in advance! \documentclass[a4paper,twoside,10pt]{report} ...
2
votes
1answer
65 views

newcommand that does not expand at all

How do I define a command that exactly inserts its contents back into the source file without any reinterpretation, expansion, etcetera? In other words, I want there never to be a difference ...
2
votes
2answers
58 views

switching between newcommand and default

I've defined the following macro: % makes tables more readable \renewcommand{\arraystretch}{1.1} \setlength{\tabcolsep}{5pt} Which add extra tabbing space in the tables. However, in one place ...
0
votes
1answer
49 views

Referencing my own command

I'm trying make my own command for a requirements document. I'm now looking for a way to reference my requirements. This should be possible by using \ref and the later on with the hyerref package. ...
2
votes
1answer
41 views

Arithmetic in tabular lengths ( p{…} )

I'm trying to do some simply arithmetic for a dynamic column type in tabularx. What I want is to be able to calculate (n-1) * X. I tried to use the calc package, but I just cant figure it out. ...
0
votes
0answers
28 views

When should one place an % at the end of a line to prevent the insertion of unwanted space [duplicate]

I understand that a % character at the end of a line prevents the insertion of a space in the text. However when creating macros I am unclear when you should place a percent sign at the end of a line, ...
1
vote
2answers
55 views

Numbered \newcommand without enumerate

How to add numbered problems within chapters and sections but not with enumerate. Problem must have variable as defined below. \documentclass[10pt,a4paper,oneside]{article} ...
4
votes
1answer
75 views

Extract the last word from a sentence stored in a variable

I want to extract the last word of a sentence stored in a variable, e.g. \thevariable. Here is the minimal example. \documentclass{article} % Function to extract the last word of a sentence ...
5
votes
3answers
176 views

Generate a table with 19 arguments using key-value interface

I'm doing my bachelor thesis, and need to make a table with lots of data. I want to make a macro for that table, since I'm going to use it a few times. Considering egreg's answer in this question, ...
7
votes
2answers
154 views

Why does twocolumn mode break usage of \AtBeginDocument{}?

I've been happily using the multicol package to layout a set of documents that are generated for multiple output formats from the same source. By necessity this moves same code from the document ...
2
votes
1answer
29 views

Nested commands with parametrized names

Inside a command I would like to define multiple new commands. Their names are parametrized by arguments, but they should also be able to call each other during definition. Here is an example: ...
4
votes
0answers
66 views

guess a number proportional to another [closed]

This is a challenging question. I am not sure how to begin coding it, or whether it is easily possible in TeX. I wish to define a command that takes in input of a simple formula such as Z = X x N + ...
1
vote
1answer
44 views

Spacing after alias [duplicate]

I'm not sure whether I am repeating an already existent question or not, but I'd like to know how to approach the following situation: I want to define a macro to be an alias to some word or fragment ...
11
votes
2answers
93 views

split off function for variable as separator

How/Possible to change this implementation of \xSplit so that the separator is a variable filled in at the time of definition (\edef somehow?) or at the actual use of the command?? %based on the ...
5
votes
2answers
90 views

How can I use \XeTeXcountglyphs\font in a pgf \foreach macro?

Problem I keep getting: You can't use `\XeTeXcountglyphs` in vertical mode. Attempt \documentclass{article} \usepackage{fontspec} \usepackage{pgf} \usepackage{pgffor} \begin{document} ...
3
votes
1answer
95 views

Where is \printtoctitle defined?

I can use \show\printtoctitle to get its definition, > \printtoctitle=macro: #1->\printchaptertitle {#1}. l.5 \show\printtoctitle but grepping for it through my latex installation I don't ...
4
votes
2answers
115 views

macro help with $\mathbb{Z}/p^{a}\mathbb{Z}$

I am using \mathbb{Z}/p^{a}\mathbb{Z} many times in my work with variable a, I was thinking can I define a macro like \Z_p^{a} which will give the above result. I tried ...