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

4
votes
1answer
59 views

Drawing an oval around Text using postscript in latex and also create a macro for the same without tikz package

The solution is simple when I use packages like tikz. But I am not supposed to use packages. I need to use post script in latex. I am trying to draw this oval using two lines and two curves in a macro ...
3
votes
0answers
32 views

How to restrict TexStudio macro script to work only in text/normal mode?

I understand that you can write (?highlighted-as:numbers,math-delimiter,math-keyword) before your trigger and TexStudio will execute the macro only in Math mode. I already tested that in "scripts ...
10
votes
3answers
186 views

How to do certain indentations

I tried searching for an answer, but franly I'm so new to LaTeX that I don't even know what I'm searching for, so I'll explain what I'm trying to find below. I would like to have this as one of my ...
5
votes
2answers
116 views

Using macro with optional argument inside macro with optional argument

I am trying to define a macro that has an optional argument that can take a macro with an optional argument as an argument. A minimal example to explain the problem more clearly: ...
1
vote
1answer
39 views

How can I get a count of the optional arguments with xparse? [on hold]

Question Is it possible to get and store a count of the optional arguments actually passed to an xparse declare argument/environment? Purpose Regardless of the number of arguments provided ...
4
votes
2answers
88 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 ...
2
votes
2answers
64 views

newcommand for pictures

I am writing my thesis and I want to include pictures via a single command. I am fairly new to LaTeX, so I do not really get it. So far I tried this: \newcommand{\pic}[4]{ \begin{figure}[h!] ...
33
votes
2answers
3k views

Why Different Commands for Seemingly Similar Tasks?

Take a look at the following list: \textit, \it, \emph, \itshape, \mathit \textbf, \bf, \bfseries, \mathbf ... One might say, for instance, that: \mathbf and \mathit are for math mode, while the ...
1
vote
0answers
150 views

Calling filename@parse inside a command definition fails [duplicate]

I am trying to redefine \includegraphics to both auto-label the included figure and to restrict the maximum width. The auto-labeling is done by transforming the base filename to camelcase using the ...
5
votes
2answers
54 views

Problem declaring newcommand with tikzpicture inside

I plan to put some common commutative diagrams and short exact sequences as new commands in my *.sty file. However, putting this code in my *.sty file \ProvidesPackage{myLayout} ...
8
votes
0answers
66 views

3n arguments in a macro (n is an even number) for curves whose thicknesses increase or decrease

For some mathematical figures it's nice to be able to vary curve thickness smoothly along a path, to reproduce hand drawn mathematical figures made with inking liners for instance. One way to do it ...
4
votes
2answers
219 views

Macros formatting/arranging words {A_1}{A_2},…{A_n} into predefined paragraph for varying n and tagging

How does one robustly (without breaking most environments) construct the macros with arbitrary number of parameters that output the parameters into a predesigned paragraph such that several of these ...
2
votes
1answer
44 views

Getting sequences, macros, lists, and such expanded(confused)

I'm trying to do some very basic programming tasks(but as usual TeX makes this extremely time consuming and difficult (for me, of course) ;/) The problem is that I can't seem to get LaTeX to expand ...
2
votes
0answers
13 views

Append text to the title [duplicate]

In a class file I want to append an email address to the title. My naive approach was: \AtBeginDocument{ \title{\@title – [email]} \maketitle } But this just doesn't work. If I do ...
1
vote
1answer
57 views

TexStudio: Multiple Cursors in Macro

however looking up my questions using the usual suspects (Google, search function etc.) I could not find an answer/solution to the following task (potentially I don't know the proper name of the task ...
8
votes
2answers
199 views

How can I make a command available inside another command's argument?

When I define an environment with \newenvironment, I can use newcommand inside the "before" part, to make commands available to the code inside the environment. Is this possible with simple commands? ...
7
votes
1answer
56 views

It's safe to ignore tabs and newlines when defining a macro?

I've written several LaTeX environments to format a "use case flow" sequence for a college project. Being a computer programmer, I find quite annoying to not be able to use newlines and indentation ...
3
votes
2answers
66 views

an \underhat and \underwidehat

So $\hat x$ and $\widehat x$ give upper hats of different length, however, unlike \overbrace{} had an \underbrace{}, one sometimes needs an \uhat and \uwidehat. What is the best (cleanest, fewest ...
1
vote
1answer
31 views

Environment that eats up (ignores) text inside it [duplicate]

I want to replicate the environment comment from the comment package: \begin{comment} Hidden stuff. \end{comment} which prints just nothing, instead of using % to comment things out. I can do it ...
0
votes
1answer
28 views

Using fully expanded result as a simple string (with citet and \IfSubStr)

I am breaking my head with that problem, without finding anything that could help on Internet : The initial problem is that I write an essay in French but I need to include some articles written in ...
0
votes
0answers
22 views

Is there a possibility to follow where/when a macro is being redefined

I am currently trying to solve several bugs for witch it would be convenient if there exists a system in LaTeX where you can "spy" on a certain macro. I am interested in where/when a macro is being ...
2
votes
0answers
73 views

advanced LaTeX course

I am looking for some tutorial or video-class or something like that about LaTeX advanced course. I want to know more about macros and the creation of packages. Thanks for the attention!
3
votes
1answer
19 views

index, acronym and sorting, macro expansion

I want to use index together with acro: Whenever I use an acronym, I want it automatically in the index. However, not the abbreviation but the long name! What I did: I created a new command: ...
0
votes
2answers
30 views

Parenthetical clauses with a mechanism similar to csquotes' MakeAutoQuote

I have the following macro for writing parenthetical clauses: \makeatletter \newcommand\incise[1]{% ---\,#1% ...
15
votes
2answers
2k views

Command/macro name cannot include numbers and symbols

I would like put picture into table, and my idea is define new command as below> \newcommand{\EJ471}{\includegraphics[scale=0.150]{EJ_471.jpg}} But compiler reports an error. If I use the command ...
2
votes
1answer
29 views

Using \newcommand with ellipse in tikz

I want to use some constants, height and width, when creating an ellipse but it won't work with \newcommand. Here is a minimal example: \documentclass[12pt, a4paper]{article} \usepackage{amsthm, ...
3
votes
3answers
82 views

NewDocumentCommand with argument specifiers stored in macro

I am trying to write some macros that in turn automatically generate other macros, depending on options etc. I wonder, if it's possible to use \NewDocumentCommand{\somename}{\standardargs}, i.e. the ...
1
vote
0answers
69 views

Failure After Using Latexdiff Script: latexdiff marking up lstlisting environment

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 ...
2
votes
1answer
57 views

rewrite comand like a [key=value] using xparse or latex3 syntax

I've written a macro to use some command like a ltxdoc (\oarg,\meta,\marg) without using the textcomp and ltxdocto colorate and decide the font style with which the angle, brackets and text in ...
96
votes
3answers
18k views

What is the difference between \let and \def?

What is the difference between the \let and \def commands in TeX/LaTeX? Ideally please provide a simple example that will illustrate the difference between them.
181
votes
5answers
33k views

Space after LaTeX commands

I have a definition \newcommand{\arnold}{Arnold Schwarzenegger} when I refer to it by \arnold is a it is rendered as Arnold Schwarzeneggeris a In order to have a space in front of "is" I ...
11
votes
3answers
263 views

Treating the contents of a TeX-style group ({\blah …}) as macro arguments

I am trying to make adjustments to a large document that uses TeX-style macros, like this: {\defun SomeFunctionName arg1 arg2} The \defun macro is defined as \newcommand{\defun}{\tt}. Can I ...
2
votes
1answer
33 views

Detect whether there's space before and after macro

My document has a custom macro called \newcommand{\myparenthetical}[1]{[#1]} However, I want to be sure that in the document I always have a single space before and after the macro. I would like ...
9
votes
3answers
722 views

Detecting \global, \long, \outer, \protected

Is there a way to detect whether or not the next assignment is going to be \global, \long, \outer, or \protected? That is, is it possible to write a command \detectmodifiers such that code like ...
2
votes
1answer
35 views

Passing complicated argument patterns to a new command

I am using the nice changes package. Which basically provides three commands \added, \deleted and \replaced. Because of the structure and the fact that the optional arguments it takes, I think it is ...
0
votes
0answers
23 views

latex package for applying a diff file [closed]

I want some latex package which could applies a diff file. The package read from file.old and file.diff, applies the diff patch, and writes to file.new. If there is no such package, which packages ...
3
votes
1answer
73 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 ...
6
votes
1answer
5k views

Remove comma from moderncv's \cventry

This image shows the excerpt of a CV produced with the moderncv document class: Notice that after the bold text there is a comma. This seems to be produced automatically. How can I stop this?
14
votes
2answers
234 views

How to define a wrapper to a command that takes an optional argument?

What is the proper way to define a wrapper to a command which takes an optional argument (such as \chapter)? I mean a wrapper, not a clone, such that we can inject code into the wrapper without ...
1
vote
1answer
26 views

How to pass text/strings from main file to beamertheme via beameroptions or is there an alternative way?

In this and this question I learned how to pass simple definitions like a location from my main file to a e.g. beameroutertheme. However this approach fails for longer strings or text blocks, in this ...
2
votes
0answers
17 views

\ifbeamer@anotherslide and \ifbeamer@localanotherslide in beamerbasedecode.sty

At the beginning of the source file beamerbasedecode.sty of beamer class, two switches are defined: \newif\ifbeamer@anotherslide \newif\ifbeamer@localanotherslide By reading beamerbasedecode.sty ...
5
votes
1answer
44 views

Unused \setbox0 in beamerbasedecode.sty

Inside the source file beamerbasedecode.sty of beamer package, there are the following lines: \def\beamer@stoptexts{| stop:0| } { \catcode`\|=13 \catcode`\:=13 \catcode`\,=13 ...
1
vote
0answers
24 views

How to include input filename in error message?

I want to add an error message to a class I'm building for when the user (which will generally be me...) forgets or messes up a macro call sequence. I can do this: ...
0
votes
0answers
40 views

script to create a table with multiple rows

I'm wondering how to quickly put a bunch of data into a table. I have a rather basic knowledge so I'm asking for a way to read in data by the following format: It has 4 columns, first is formatted in ...
3
votes
1answer
48 views

tikz/pgf upgrade and decorations

Since a major upgrade in pgf, my code does not compile any more. I am trying to make "decorated" source listing, where the decorations can be like highlighting some lines (see the MWE), balls on some ...
2
votes
1answer
43 views

Disable some xunicode macros in case of T1 font encoding?

I was hoping that, except for inputenc/fontenc versus fontspec, old .tex files encoded in UTF-8 could be used without changing anything with either pdftex, xetex or luatex engines. But the following ...
8
votes
1answer
44 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
21 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} ...
3
votes
0answers
63 views

Convert Plain TeX automatic table generation macros to LaTex

I have written code, given at at the end of the post, to typeset exams and quizzes in plain TeX. A typical test would be typeset using: \def\CLASS{Math 111} \def\TERM{Spring 2015} \def\TITLE{Quiz 3} ...
2
votes
2answers
112 views

Why is this macro putting an element of a table on the wrong row?

Consider the following MWE: \documentclass[a4paper,10pt]{article} \newcommand{\macro}[2][]{% & something & #2 & #1 \\ } \begin{document} \begin{tabular}{lccc} \macro{3}{4} ...