{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
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
163 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
46 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
71 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
82 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
45 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
224 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. ...
6
votes
1answer
59 views

\let vs hyperrref

In the following sample from my custom syllabus class, I am getting a new error since updating my TeXLive 2015 distribution to the most recent release today. The error is TeX capacity exceeded. As ...
2
votes
3answers
47 views

Create and use macro names dynamically within a loop for redefining lowercase greek letters

This is follow-up question to this one. My aim is to let greek letters behave the same like normal latin letters, when it comes to get them upright. At the moment I'm using \mathrm to get letters ...
4
votes
2answers
116 views

Plain TeX end of proof macro

I am writing a macro to typeset proofs of theorems. By getting rid of irrelevant (for this question) things, it simplifies to \def\demo#1\enddemo{\noindent{\it ...
0
votes
0answers
34 views

How to code “if (#3 is not empty) then (do something) endif” in LaTeX? [duplicate]

EDIT: Answer found here: How to check if a macro value is empty or will not create text with plain TeX conditionals? Consider the following code snippet from a .sty file \makeatletter ...
2
votes
2answers
45 views

Redefining chapter conflicts with acronyms in memoir

I redefined \chapter* but when I use acronyms from the glossaries package, I get a bunch of errors. A minimal (non-)working example: \documentclass{memoir} \usepackage[acronym]{glossaries} ...
3
votes
2answers
101 views

How to patch with \xpretocmd and \xapptocmd a command by applying to it a macro with argument?

Suppose I'd like to patch a very complicated macro, say \autocite. For this, xpatch package is my friend. If the patch consists in applying a modal command which doesn't take arguments, such as ...
1
vote
0answers
37 views

Replace a nested LaTeX command with multiple arguments [closed]

I'd like to replace the LaTeX command \teilseiten{left col width}{left col text}{right col text} by an nested environment. The problem is, that the second and third argument of \teilseiten contains ...
1
vote
1answer
51 views

How to create two \newcommands from one variable #1?

Consider the following code snippets: a) Text to be printed in some document using command \defPrimitiveRoots \Snippet{\defPrimitiveRoots}{Integers with primitive roots}{ Let $n,k$ be ...
1
vote
1answer
41 views

xparse command definition vs \newcommand [duplicate]

Maybe my question is too broad, but I'd really like to know: what is best to use (and why) between xparse command definition (e.g. \NewDocumentCommand) and LaTeX "standard" definitions (e.g. ...
3
votes
1answer
50 views

In expl3, how to reset a seq variable when content is placed in footer or float?

This answer explains how to use expl3 to store a seq variable to place content later in a document. I'd like to write a command that: Writes the first argument to the main flow of the page. Writes ...
6
votes
4answers
79 views

How to make commands that gather arguments and place in later section?

I'd like to roll my own commands that achieve something similar, in principle, to how \index places the indexed term in a later section, or how footnotes place text in a footer. \summaryandextended{ ...
9
votes
2answers
225 views

Where can I look up LaTeX commands? [duplicate]

I am a beginner in LaTeX. There are some commands that I don't understand (for example \mathop and \operatorname). I want to find some material about them, but I don't know where to look. What is a ...
1
vote
0answers
26 views

How to create command that associates pieces of content to keep them on same page?

I've pieced together a class for my preferred format of Cornell notes, and it allows for floating a summary to the bottom of a page. But, it requires manually choosing the page that will host the ...
2
votes
1answer
71 views

Expansion of \newcommand

The problem I am having is certainly due to my lack of understanding regarding the details of how \newcommand, \def, \edef, \let, etc. work, though I happened to encounter the problem when making use ...
1
vote
2answers
41 views

How can I input only certain columns using macros outside csvsimple?

I want to define a command, like \newcommand \Fruittype {Strawberries} and only input the data from the column that contains it. Can someone help me? \documentclass[a4paper,12pt,hidelinks]{article} ...
6
votes
1answer
123 views

Set the default value of argument as parameter in newcommand

I want to define a command that will emphasis the keywords and add it to the index at the same time. This can be archived by \newcommand{\iemph}[1]{\emph{#1}\index{#1}} But the problem is that, I ...
3
votes
1answer
51 views

How to do simple arithmetic computations with variables to manipulate other input parameters in latex?

I am trying to make a template for my CV. I need to make different color shades for headings, and subheadings many more. I figured out how to make variables in latex such as r,g,b shown in cod below ...
3
votes
4answers
193 views

How could one change the catcodes inside the definition of an environment?

I tried to find a clever and robust way to use non-letter symbols like %, _, ], [ etc.inside the definition of an environment. I tried for example to change [ and ] to letters for using them locally. ...
2
votes
4answers
240 views

Is it possible to use non-letter symbols instead of backslash in the definition of a command?

I am trying to define new commands starting with other symbols instead of the \(backslash) The use of \backslash is not so intuitively for non-experienced LaTeX users. So I would prefer to use ] , [ ...
0
votes
0answers
12 views

How do I use a custom LateX package? [duplicate]

I want to draw some Signal Processing plots in my document, and found a package called dsptricks on ctan. I downloaded the .sty files, copied them to /usr/share/texmf/tex/latex/dsp_stuff, but am now ...
1
vote
1answer
60 views

Use path replacement command inside tikzpicture/pgfplots table

After using the answer of Using \nameref within \path I tried to use that command inside a 'pgfplots' table as file name. Here's the (shortened) code: \newcommand*{\expath}[1]{/Users/jo/{#1}} ...
5
votes
3answers
142 views

Where to define new TikZ commands

I have to start by saying that I am a newbie to LaTeX, let alone TikZ. In order to solve another problem, I found a solution in another question in a comment by Tom Bombadil. He defines the new ...
1
vote
1answer
79 views

Is it possible to get rid off of { and } in the definition of a command?

My purpose is to write simple commands that put graves and other accents symbols above Greek letters. I am facing the following problem: Let say \grave{i} puts the grave symbol above I (for example: ...
3
votes
1answer
26 views

How to put non-return function and return function in \newcommand?

During my work, I came across a need to insert pages from PDF document (which i used \usepackage{pdfpages} and \includepdf[option]{doc.pdf}) and I wanted to add these pages into \tableofcontents with ...
3
votes
1answer
59 views

Redefine norm symbol \| as \left\| or \right\|

I'm currently using the following macro: \def\norm#1{\left\|#1\right\|} Is it possible to redefine \| so that \|\frac{a}{b}\| produces the same output as \norm{\frac{a}{b}}? Why? Not only I find ...
2
votes
1answer
74 views

Redefining command outside math mode

In LaTeX2e, Is it possible to redefine a command, yet have the scope of the redefinition apply itself only outside math mode? For instance, I'd like to redefine \sec to \section, but unfortunately ...
-1
votes
1answer
43 views

How to load different macros for different files

I have a thesis with a common macros file for all the chapters. I would like to not load this file in my cover.tex which is loaded from a thesis.tex file as \input{cover} but after the cover. How ...
4
votes
2answers
139 views

Centered hat over bold letter with subscript in \newcommand

I'm relatively inexperienced with LaTex and I'm trying to use \newcommand in a larger project. I have several cascaded \newcommands that I can't get to behave the way I want: ...
1
vote
2answers
74 views

Macro in texstudio/texmaker to surround selected text with tags

When you use some of the predefined shortcuts in texstudio on selected text, it wraps the text with the appropriate tags(is that the proper term?). For instance, suppose i highlight Hello Worldand ...
3
votes
1answer
89 views

Automatically add \noindent for short paragraphs

Is there a way to activate \noindent to each line which is so small that there is no line break in the paragraph? An example: The code This is a long paragraph: Lorem ipsum dolor sit amet, ...
1
vote
0answers
62 views

HZ typesetting system in plain TeX

How can I use the hz typesetting engine with plain TeX and pdfTeX? I read about it in TUG Vol 36 no.2, Peter Karow article, link: TUG Vol 36 no.2, Peter Karow.
1
vote
0answers
35 views

Why \@M instead of 10000? [duplicate]

Reading code from packages/whatever, I often find commands like \@M, \p@, \z@, \m@ne, \@ne, \tw@ etc. What is the point in using those instead of the (IMHO more understandable) 10000, pt, -1, 1, 2 ...
1
vote
2answers
57 views

Construct and print name lists with macros

I have to print author lists in different places. In the cover the author should be printed as Name1 \\ Name2 \\ Name3 But in other places it should be printed inline. Name1, Name2 and Name3 I ...
2
votes
1answer
54 views

Make brackets appear when I refer to an equation (with the help of \def or \newcommand)

I want to define a newcommand that allows me to write just \ref{Label} instead of (\ref{\label}). I tried \newcommand{\reff[1]}{(\ref{[#1]})} and \def\ref[#1]{(\ref{#1})} but both of them did ...
6
votes
2answers
152 views

A problem with newcommand

In the following code \documentclass{article} \usepackage[usenames,dvipsnames]{xcolor} \usepackage{tcolorbox} \usepackage{tabularx} \usepackage{array} \usepackage{colortbl} \tcbuselibrary{skins} ...
4
votes
1answer
48 views

Is it possible to defer expansion of an object's contents until all content has been created?

I want to provide author-usable macros in my package to store data that will later appear in a table, but it would be nice to allow authors to define the data in that table at any time, even after the ...
1
vote
2answers
84 views

Macros in LaTeX class

I have the following macros in a LaTeX class: \def\labelenumi{\theenumi.} \def\theenumi{\arabic{enumi}} \def\labelenumii{(\theenumii)} \def\theenumii{\alph{enumii}} \def\p@enumii{\theenumi} ...
6
votes
2answers
125 views

How to extend existing macro with \edef?

\edef does expansion, but does not execute the commands. How in the following example make so that \foo will do assignment to \tmp at the moment of its call, not when it is defined? Why \foo produces ...
6
votes
3answers
134 views

How should I /protect this command for use in \csname?

In the process of learning how to use \csname, I'm trying to create a macro that allows one to specify integers as arguments and then will yield some content specific to the arguments, like this: ...