Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [macros]

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

1
vote
1answer
23 views

Use of \p@COUNTER

When a new counter is defined via \newcounter, e.g. \newcounter{mycounter} then a command \p@mycounter is also defined. I can see this again popping up when setting the \@currentlabel in \...
0
votes
2answers
24 views

How to have “preprocessor” flags in LaTeX [duplicate]

C programmers often use constructs like #ifdef foo printf("foo is defined "); #endif #ifndef foo printf("foo is not defined "); #endif to select certain code-paths during the compilation ...
0
votes
0answers
25 views

conversion problem [on hold]

please guys i need this to be translated in text for me,i have tried my best and it's not working out 7VV4 III V VIII IV 9 IV 7 II V XII5 9 I IV V XIII XV V XI 31 IV IV V X 453V45 X89IX ...
1
vote
1answer
38 views

Misplaced \omit in table and {} at the end of a command

The following LaTeX document does not compile. \documentclass{article} \usepackage{booktabs} \usepackage{ltablex} \usepackage[]{multirow} \usepackage{lipsum} \begin{document} \noindent{} \begin{...
0
votes
1answer
24 views

pylatex Command

I'm using pylatex and I need to attach a logo in the header. I want to use this latex example: \documentclass{article} \usepackage[tmargin=3cm,lmargin=3cm,rmargin=2cm]{geometry} \usepackage{...
1
vote
1answer
24 views

Prepare my document for submission to a paper

I am preparing my document to be submitted to a journal via ScholarOne Manuscripts™. I have read in their online documentation Here, that I need to do the following: Embed fonts Remove macros ...
2
votes
4answers
92 views

Changing the effect of a command in another

I'm currently trying to define commands such that: \x{F}{a} gives F^{(x=a)} \y{F}{b} gives F^{(y=b)} This I can do fairly easily: \newcommand{\x}[2]{\ensuremath{{#1}^{(x={#2})}}} However, I ...
3
votes
1answer
53 views

Include tikz image in other text files of each chapter

I am working on a book which each chapter has an image .jpg or .png. The code that accomplishes this is: \newcommand{\thechapterimage}{} \newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#...
0
votes
1answer
38 views

Newcommand alert

I would like to create a new command, like \alert, but in other colours and if it was possible to combine it with the comand \pmb. I mean in the first frame shows 2x+1 and after a click \pmb{2x+1} (...
25
votes
3answers
473 views

Why \underbrace has _{…} instead of an optional parameter?

Why is \underbrace (and similar commands) in the form \underbrace{my formula}_{some text under my formula} ? Shouldn't a standard macro be in the form \underbrace[some text under my formula]{my ...
3
votes
1answer
54 views

\pdfminorversion on the command line?

Is it possible to set the pdfminorversion on the commandline when calling pdflatex, instead of using \pdfminorversion=... in the tex file ?
1
vote
2answers
39 views

Changing the font used by \SetPaperName in 'newsletter' package

I'm trying to change the font of the newspaper template which you can find here and which is described there. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{...
2
votes
2answers
61 views

Make paired delimiter with prefix for Re and Im

I'm trying to make a new command for something like this: \operatorname{Re}\left\lbrace\num{1+2i}\right\rbrace Because I'm using the mathtools package already I tried to do something like this: (And ...
1
vote
1answer
21 views

Tilde in listings using lineskip and a command breaks “onehalfspace”

I'm trying to produce an inline code snippet that starts with a ~. Using onehalfspacing per university requirement and lineskip=-1pt for subjectively better legibility, packing the \lstinline inside ...
2
votes
1answer
53 views

Using exam question counter as an argument

I am trying to use the exam class to create a study guide for my students that has all of the answers at the end of the document. I would like to have the answers automatically labeled by question ...
0
votes
2answers
39 views

Custom Environment Multiple Inputs

I'm trying to write a new environment for the AIAA package (mostly just for fun/learning). I want to take the authors section: \author{ First A. Author\thanks{Job Title, Department, Address, and AIAA ...
1
vote
2answers
76 views

Conditional environment

In a huge document, I would like to use 'env1' or 'env2' environment depending on the value of a global variable 'flagenv'. How could I define an environment 'foo' so that I can write something like : ...
3
votes
4answers
166 views

Expanding macro twice

How would you expand a macro twice in LaTeX 2 (or 2epsilon). I am aware of the question What is the preferred way of expanding twice in expl3?, but I'm curious as to how you'd do it in LaTeX. I'd ...
2
votes
1answer
97 views

A simple macro with tikzcd - fork diagrams

I am trying to create a macro to easily draw forks as this one: I tried this: \newcommand{\fork}[6]{ \begin{center} \begin{tikzcd} #1 \arrow[r, "#2"] & #3 \arrow[r,shift left, "#4"] \arrow[...
1
vote
1answer
53 views

Two columns on a \newcommand

I'm making my CV. I have the following command declared: \newcommand{\cvevent}[4]{% {\large\color{emphasis}#1\par} \smallskip \textbf{\color{accent}#2}\par \smallskip {\small\makebox[0.5\...
7
votes
2answers
363 views

Floating point square root symbol

For my numerical analysis class, we use a certain symbol to represent the floating point square root operation (similar to using \ominus for floating point subtraction, \oplus for floating point ...
1
vote
1answer
25 views

Missing number, treated as zero when using renewcommand

I am trying to temporarily get read of marginpars in my paper. I tried to simply \renewcommand{\marginpar}[]{} but I get: ! Missing number, treated as zero.<to be read again>} \renewcommand{\...
0
votes
1answer
29 views

Split string variable by spaces

I am updating a custom latex class but I am a newbie with Latex and I need to parse a command like that \author{First Middle Last} into a new one \author{Last}{First Middle}. I cannot provide the \...
5
votes
2answers
174 views

\immediate\write with plain text

I have read the question in TeX.SE, but I don't want user to add ^^J manually. That is, I want writer to output content originally. \documentclass{article} \begin{document} \newwrite\file \immediate\...
0
votes
1answer
59 views

Expand all \newcommand without doing anything else in LaTeX? [duplicate]

Can I expand all \newcommands without doing anything else in LaTeX? Edited: My true goal is standardizing math papers in plain text so that theorems and definitions can be accurately and easily ...
3
votes
1answer
74 views

Define a \<name> and \end<name> pair directly rather than define an environment called <name>?

While defining an environment <env> also defines the \<env> and \end<env> declarations, what are the circumstances where defining those declarations directly (without defining an ...
10
votes
1answer
489 views

Why are there no \dint or \dsum like \dfrac?

This was inspired by How to have nice-looking symbols within an \itemize environment? and Sigur's comment which remind me about the display style of math formulas and the fractions. I know that, in ...
2
votes
1answer
47 views

Is there a math package with a set of macros that would help manipulate terms in long expressions?

This semester I've been typesetting my math homeworks in Latex, and these often involve long expressions with many fractions and brackets. I'd love to be able to use macros to perform operations like ...
0
votes
3answers
37 views

How to change macro to replace \begin{theorem} … \end{theorem} by \theorem?

To state a theorem, what we do usually : \begin{theorem} ... (statement) ... \end{theorem} I want to change the macro so that I can use \theorem like \section: \theorem ... (statement) ... Is ...
6
votes
4answers
100 views

Saving arguments of commands to be used later

I'd like to create a command to print some contacts inserted with same 3 commands: \name{},\work{},\email{}. Every time we use those 3 commands, a new contact is collected and then all of them is ...
9
votes
4answers
735 views

Summing numbers like paper calculation

I need to make many of these. If it s possible numbers to be aligned right. How to do that?
3
votes
1answer
41 views

How to use a macro to specify number of lines in a \parshape

I would like to be able to use a macro to specify the number of lines in a given \parshape. So, instead of \parshape 8 ... for instance, I would like to be able to use \newcommand*{\NumberOfLines}{...
1
vote
1answer
48 views

Automatic table from list

it is possible to create a table from a list? I mean something like: Ex1 (each three elements generate a new column): \peopleA{P. Smith, A. Row, B. Streams, O. Green, L. Handley} \peopleB{A. Hause, ...
0
votes
1answer
32 views

How to write a macro to automatically create a frame with items in beamer?

I want a definition like \def\tag{......} \def\printtag{......} \tag{1.1}{ title aa bb cc } \printtag{1.1} to achieve \frame{\frametitle{title} \begin{itemize} \item aa \item bb \...
5
votes
4answers
87 views

Command to format any number of equations

I am reading many entries here on comma-separated list of arguments in new commands. I cannot get them to adapt to my needs, so here I come with my question. I'd like a command like so: \eqsRef{equ:...
2
votes
1answer
102 views

Defined command only works in preamble

I'm writing a class, and when using it I want to use small caps with a font that doesn't have small caps defined (I know – not as good as the real thing). I found this answer Fake small caps with ...
1
vote
2answers
42 views

Redefine \chapter to add \printMiniToc

I want every chapter to have \printMiniToc after it. However I don't want to have to add \printMiniToc after every \chapter. So I tried using etoolbox and tried this: xapptocmd{\chapter}{\...
5
votes
1answer
46 views

How does xparse handle nested delimited arguments?

In this answer egreg mentions that the r argument type from the xparse package handles nested delimited arguments, as shown in this small example: \documentclass{article} \usepackage{xparse} \...
8
votes
4answers
628 views

Problems with def

I have created the following macros in LaTeX: \def\twomate(#1,#2,#3,#4){\begin{pmatrix}#1&#2\\#3&#4\end{pmatrix}} \def\pwr(#1){^{#1}} \def\twoclmn(#1,#2){\begin{pmatrix}#1\\#2\end{pmatrix}} ...
4
votes
1answer
35 views

How to add an icon to a paragraph's margin?

I'd like a custom command or environment to add an image in the right margin at the top of a paragraph, which would look something like this: Here's the icon (as a PNG) I'd like to use. Related: ...
7
votes
6answers
696 views

Respectable-abbreviations macro

How might one write a macro that makes slovenly abbreviations respectable? \documentclass{article} % \newcommand\abr{...} \begin{document} I've seen it in the \abr{OED}. \end{document} What I mean ...
0
votes
1answer
30 views

remove space after writing a command when using \write

I'm writing a macro to write commands to a file. These commands are supposed to be read when building my document. The lines I use to write to the file is : \newwrite\outtest \immediate\openout\...
2
votes
1answer
43 views

Sine squared with parentheses for argument

I have a number of trig functions raised to some powers, and the arguments are often different from just t \sin^2{\frac{2\pi}{T}t} for example Now, I would like to get the argument to be in ...
1
vote
1answer
32 views

How to write the superscript above the subscript in newcommand?

I want to create a command for adding a superscript * to a variable, indicating its "optimal" value. However, when I do this, the superscript is added after the subscript instead of right above: \...
0
votes
1answer
39 views

separate the string by space [closed]

how to split parameter in an argument list of function by space \def\onto[1]{ ....i don't know how to do } or \newcommand{\onto}[1]{ #1 } in #1 i get hello home as 1 string in example i give \...
2
votes
2answers
25 views

Error while defining a newcommand

I am trying to define a new command in my Latex file like this \newcommand{\newchunk}[1][2]{\section{#2}\label{sec:#1}\quad} But I get the following error after Latex compilation ERROR: Illegal ...
3
votes
1answer
37 views

\newcommand with multiple arguments that generates a table

I would like to create a macro that can generate a table like this: \documentclass{minimal} \begin{document} \begin{tabular}{c|c|c} A & 1 & 2 & 3 \\ B & 0 & 1 & 1 \\ C ...
0
votes
2answers
35 views

\noindent inside a command not working

i looked a lot for a solution to my problem but i don´t seem to be able to find one. Here is the summary: in my document I have a custom command for a description and i would like this description to ...
0
votes
0answers
17 views

Using variable path with Input{}

I do start writing my PhD with Latex. I got a template which I am asked to work with. Inside of that template there is an include option in order to include all the required files. A newcommand line ...
2
votes
2answers
76 views

How to reuse a command inside another environment

For my own needs, I am writing a package holding some environments definitions. I also have some commands that I want to be available only inside these environments. So I define these commands inside ...