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

2
votes
2answers
39 views

New Skipping Lines Command

I use \vspace{2\baselineskip} a lot and would like to create a new command for skipping a certain number of lines. Something like \skip{2} for instance instead of using \vspace. I know about the ...
10
votes
3answers
657 views

Apply a macro to every word

In order to improve the \sameword feature of reledmac, I would like to find a way to automatically apply a command to every word. For example, in plain TeX, \def\foo#1{#1 (#1)} foo bar foo bar foo ...
1
vote
3answers
71 views

Insertion fails when invoked in \chapter

Here is the simplified version of my project. I have a macro named \CreateMacro which takes 2 inputs, i.e., the macro name to create and its body. For example, invoking \CreateMacro{Newton}{$F=ma$.} ...
2
votes
1answer
68 views

Macro to emulate \SI macro of siunitx package

I am using pandoc to convert a .tex document into a .docx. The tex document uses the siunitx package. As pandoc can not interpret the macros in the package, I have to write dummies for the macros I ...
11
votes
2answers
285 views

What is the difference between assigning and \def

What is the syntax difference between these two assignments (basically) \arraycolsep=1mm \def\arraystretch{0.7} What are the fundamental differences of the command \arraycolsep and \arraystretch ...
2
votes
1answer
66 views

Is there a way to have xesearch search and replace a term and have the replacement compiled as LaTeX command?

I have used the package xesearch https://www.ctan.org/pkg/xesearch?lang=en xesearch in my header to automatically replace shorthand notations: \usepackage{xesearch} \SearchList{list1}{Very Long ...
7
votes
2answers
131 views

Write an \unpar macro

I would like to write an \unpar macro which removes last \par. For example, the TeX code This is a \par \unpar paragraph should be equivalent to This is a paragraph (Note that by equivalent I ...
0
votes
1answer
33 views

Extra space in renewcommand

I use this code to add an extra space in the frqq command: \let\oldfrqq\frqq \renewcommand{\frqq}{\oldfrqq\xspace} It compiles, but generates an error when it is used: ! Undefined control sequence ...
1
vote
1answer
37 views

\uppercase not working with dynamic text [duplicate]

I've got some layout that I'm trying to make into something that can be parameterized with dynamic text: \documentclass{article} \usepackage{tikz} \definecolor{spotcolor}{cmyk}{.40,0,.70,0} ...
2
votes
2answers
92 views

Set italic text failed in new command definition

I'm defining new commands in my .tex file. Here's my code: \newcommand{\subhead}[1] { {\itshape \flushright \subheadfont --#1 \par} } I'm going to define a command that make some text(from ...
2
votes
1answer
88 views

Create a table of todos

I'm working out notes from a meeting in LateX. During the meeting I write down so called "todo's" (not to confuse with the todo package). I use my own command TD to simplify my layout, it basicly ...
6
votes
2answers
119 views

Square brackets [ ] as first text inside environment

I had a case where I wanted do start a text with a square bracket inside an environment. It was interpreted as an optional argument. My workaround was to insert a {} to separate that. Is that the way ...
2
votes
1answer
47 views

Preview Package in LaTeX trim the \widetilde

Forgive my dummy question, i am not professional in LaTeX. I use Preview package to crop the inline formulas' borders exactly to the mathematical notation but i noticed the following: after using ...
2
votes
3answers
99 views

Evaluate binomial coefficient with \pgfmathtruncatemacro

How is it possible to evaluate complex formulas like \binom{2^{4}-3}{2^3} with \pgfmathtruncatemacro ? I want this to evaluate to 1287. What already works: \begin{tikzpicture} \foreach \l ...
0
votes
0answers
73 views

Pattern Recognition Letters, Keywords do not show up

I am editing an article for the journal "Pattern Recognition Letters" using the according template. I have replaced the dummy words with my keywords, but the keywords still do not show up in the PDF ...
1
vote
1answer
50 views

how to simple \begin{array} using \def?

I want use \def to simplify the \begin{array}. Here is the code \def\ba#1{\begin{array}#1} \def\ea{\end{array}} $$ \ba{ccc} a11 & a12 & a13\\ a21 & a22 & a23 \ea $$ I got error. I ...
2
votes
1answer
22 views

Store text command containing itemize in a variable

The problem is that I have created a variable containing a text with some itemize environment. Now, for some reasons, I want to store the content of it in another variable. But it's not working (see ...
5
votes
3answers
92 views

Macro for creating trees for B-series as math symbols

I am writing a paper on numerical solutions for ODEs. For the representations of B-series I want to use binary tree-like symbols. I know how to produce them with TiKZ; however, just as in the given ...
1
vote
2answers
62 views

Fonts from custom math command does not get resized in subscripts and superscripts

I have a particular type of symbol in my document that I want to typeset in a different font. Hence, I defined a macro \tn to make this shorter. After several attempts, I ended up with the definition ...
2
votes
1answer
25 views

Redefinition of \- (discretionary hyphen): does not apply to a minipage?

I would like to redefine \- (discretionary hyphen) as part of several shortcuts for arrows, like \-> = \rightarrow or \<- = \leftarrow, especially useful for the often used equivalence arrow ...
2
votes
1answer
35 views

On demand ad hoc counters

Is it possible to define a command \mycounter{<par>} in LaTeX which does the following: if a counter with name <par> exists then increment the value of that counter and print the ...
8
votes
1answer
395 views

How to redefine the “plus” symbol?

Let's say I don't like the way the + symbol is printed inside equation: is there a way to change its appearance without defining a new command? More generally, is it possible to create a command ...
3
votes
1answer
75 views

Automatic abbreviation of names

Is there a package or command that can automatically abbreviate names (similar to what bibtex does but not specifically for author names or citations)? The goal is to have a command that generates ...
5
votes
3answers
192 views

How to maintain macros file?

I maintain a macros file which is static over all my documents. Whenever I need to make a new document, I copy the macros file in the folder and start working on it. Now the problem is I have several ...
3
votes
1answer
69 views

I have a word “Prof” repeating in my Latex document. Can I make a string variable which can be used for later references?

I am writing a long document which references various Profs (and their names ) in my document. I wanted to make some variable so that I can just use that whenever I wanted to write "Prof.". Is there ...
2
votes
1answer
41 views

obeylines command is not working inside a definition [duplicate]

The problem is that \obeylines macro is not working while it's inside \def Compare: \long\def\linesaver#1{\obeylines#1} \linesaver{ Test1 Test2 } VS { \obeylines Test3 Test4 Test5 } First does ...
7
votes
3answers
188 views

Macro like `\ignorespaces` for ignoring `\par`s

I would like to have a macro \ignorepars that removes all \pars following it. I wrote the following code: \def\eat{} \def\ignorepars{\futurelet\next\ignoreparsA} ...
3
votes
1answer
85 views

how to auto turn only the first letter of chapter into uppercase?

I want to auto turn only the first letter of chapter, section and subsection into uppercase. Can this solve that? \usepackage{titlesec} \titleformat{\section} ...
1
vote
0answers
24 views

Latex tikspicture environment : replacing some tikz commands with a macro [closed]

I try to replace part of tikz commands inside a tikzpicture environment, with no success so far. Examples: \newcommand{\drawIt}{\path [draw] (4,100)--(5,150)} \begin{tikzpicture} \path [draw] ...
1
vote
3answers
104 views

Optional parameter in newcommand

I have made a command \newcommand{\mysec}[2]{% \textbf{#1} \\ #2 } I use it with \mysec{A}{B}. But sometimes I also want a third parameter. I could make a whole new command for those situations ...
4
votes
1answer
113 views

Macros for redefining \maketitle

I have a document with multiple \maketitle tags. I would like macros that will allow me to redefine the title with a single command. While the code below produces the output I want, ...
11
votes
1answer
181 views

What does the prefix “\c@” mean in build log?

I just follow the LaTeX tutorial to create the first "Hello World!" .tex file, and translate it to PDF file. Then I go through the .log file and see the following, ("C:\Program ...
1
vote
0answers
32 views

Protecting \@ifnextchar inside pgfplots

I'm having trouble figuring out what I need to do in order for my definition of \sin to be accepted by pgfplots. I've looked up stuff about using \protected but it's vague to me how I'm supposed to ...
2
votes
0answers
51 views

Spoilers in Web-Accessible Pdf Documents?

A highly regarded professor of mine is currently writing a graduate mathematics textbook in which he has given the book a theme of ``do it yourself'' mathematics. He has asked me to review the book ...
17
votes
1answer
504 views

How to display LaTeX code and the typeset version next to each other without repeating myself?

I would like to write some LaTeX code, and without repeating myself, I would like that to be used for displaying that particular piece of code as-is and its typeset version, next to each other. The ...
0
votes
1answer
94 views

New command causes undefined control sequence [duplicate]

I want to create a new command to set the column colour, but it's causing the following error: ! Undefined control sequence. \redcolumn ->\columncolor {red} l.10 A & ...
2
votes
2answers
67 views

How to stop a custom \section macro from adding whitespace to the beginning of a paragraph?

I lifted a \section macro from the TeXbook. \outer\def\section#1{\medbreak\noindent{\bf#1}\smallskip\par\nobreak\noindent} When I use this macro like this: \section{\TeX nical documenation} Blah ...
0
votes
1answer
24 views

Two `minipage` inside command

I want two minipages side-by-side. I can do this easily. But then I want to turn it into a command, and the minipages don't line up any more, even thought the code looks identical. What is wrong? ...
1
vote
2answers
26 views

Difficulty in creating command for right alignment of text

I am trying to create a command for right alignment of text. The text must be kept on the same line if it fits on the line, else it must flow to the next line but must keep the alignment (right ...
5
votes
1answer
51 views

String concatenation macro to find file in pgfplots groupplots

I have a strange problem with pgfplots and using a macro to return a string to a file to be included. MWE Code: \documentclass[a4paper,10pt]{article} \usepackage{pgfplots} ...
2
votes
1answer
158 views

Latex \newcommand usage

I would like to simplify the way to type indicator functions. So I used package bbm and defined \newcommand{\1}{\mathbbm{1}} But I actually want something like \mathbbm{1}_{XXX}=\newcommand{1}{XXX}. ...
0
votes
0answers
45 views

Vertical, multiline, curved Fourier and Laplace club-symbol

I'm looking for a vertical Laplace and Fourier transformation symbol, similar to the one in trfsigns, but I need A vertical version of the symbol as found in the only answer to Vertical Fourier and ...
1
vote
1answer
70 views

Enumerate with enumitem and \newcommand macro

% !TeX spellcheck = he_IL \documentclass[titlepage=false,12pt,titlepage]{scrreprt} %\pagenumbering{roman} \usepackage{ucs} % unicode support \usepackage[utf8x]{inputenc} \usepackage[T1]{fontenc} ...
4
votes
1answer
83 views

Highlight first occurence of reference in text

I'm working on a LaTeX template for our institute. The guidelines dictate an unusual style when referencing figures, equqations or tables. The frist time, they are mentioned in the text, they have to ...
0
votes
0answers
80 views

!LaTeX Error: There's no line here to end [closed]

! LaTeX Error: There's no line here to end. I need help for resolver it problem my code don't want compile i believe that error is little thing but for me no is evident. I need help me to understand ...
1
vote
0answers
21 views

Macros in \ref or \pageref etc [duplicate]

I am trying to create labels using macros. I have seen somewhat related pages, but honestly nothing that solves my problem. Below follows a relatively simple minimum working example. I thought that ...
2
votes
1answer
44 views

How to compare and see if an expanded command is equal to another

Okay, I'm processing a CSV file using datatool: "TRANSID","DATE","QUANTITY" "141f8b4a-e83e-4222-911a-5a977b4d0afca","11/9/2015","10" "88cdad7e-eb21-4010-94c5-acca8ac2e559a","11/9/2015","5" ...
0
votes
0answers
37 views

Writing a macro to enclose cell values of a row in parenthesis

I asked this question How do I enclose each table column of a particular row in parenthesis around a month back, there was a suggested approach, but writing the latex macro is beyond my capabiiility ...
5
votes
2answers
219 views

Writing a command to denote the “corresponding author”

For those of you who read academic papers, you might have noticed that on some papers, there is a symbol next to an author's name that marks them as the "corresponding author". (Usually this is the ...
3
votes
1answer
59 views

Producing expandable environments with only optional arguments with LaTeX3 syntax

I am trying to create a new document environment to complete the assembly of a table (simplified for MWE) but I am having a problem combining an expandable environment with an optional only argument. ...