{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
0answers
15 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 ...
0
votes
0answers
25 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 ...
2
votes
2answers
63 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!] ...
5
votes
2answers
50 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
65 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 ...
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 ...
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? ...
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 ...
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 ...
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% ...
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 ...
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 ...
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 ...
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 ...
10
votes
3answers
261 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 ...
13
votes
2answers
232 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
43 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: ...
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 ...
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 ...
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} ...
7
votes
3answers
91 views

Use the result of FPeval to color a table cell

I am trying to give a table cell a grayscale color value based on it's numeric value. So far I have the following code \documentclass{article} \usepackage{fp,xcolor,colortbl} \FPeval{\resb}{0.5} ...
6
votes
2answers
117 views

How to typeset the percent symbol inside \detokenize?

I am writing some personal notes about R programming. I defined a macro to typeset R functions and operators using a different font style and color: \newcommand{\rtext}[1]{% ...
8
votes
2answers
311 views

Is this sacrificial command a good idea?

I have this command: \newcommand{\name}[1]{\edef\name{#1}} You first call it as in \name{Don} and afterwards you can refer to Don using \name. Is this an accetable way to express a constant that ...
0
votes
1answer
53 views

\newcomand causes failure [duplicate]

im new to Latex, so pleas make explenation easy ;) im working with latest latex version on miktex i tried some \newcommand today and caused an error with this command: \newcommand{\N0}{ n_{0} }. when ...
2
votes
2answers
33 views

Keeping underscores in parameters even inside NewEnviron environments

I followed this answer to define a command such that underscores in its parameter can be kept. However, this does not work if the command is called inside an environment that has been defined with ...
4
votes
1answer
32 views

Setting a counter to a value obtained by expansion

I use the glossaries and minitoc packages. Minitocs are generated for all glossaries printed in the table of content, eg with the toc option for the glossaries package. When one prints the glossaries ...
4
votes
1answer
54 views

How to use a command as path in 'includegraphics'?

I want to include a graphic by using \includegraphics{\mycommand} but it doesn't work. The path to the picture will be a combination of text written in .txt files. This is my code: ...
5
votes
2answers
98 views

How can I automatically replace all accentuated characters by the corresponding codes in TeXnicCenter?

First I want to apologise in case the question has already been asked, although I failed to find the topic on this site. So here's the thing : I've recently begun to type my lessons in LaTex using ...
1
vote
1answer
27 views

How to define commands for additonal information in beamer main file for use in themes?

In a typical beamer document I can set various options like \author or \title: main.tex \documentclass{beamer} \author{George Orwell} \title{Animal Farm} \date{\today} \institute[TUD] ...
2
votes
1answer
46 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 ...
3
votes
1answer
20 views

Redefine command inside page header

I’d like to redefine a command inside a page header that’s generated using scrheading. The reason for this is that the page header should be in all-low-caps; however the chapter header happens to ...
4
votes
1answer
85 views

\begin{document} breaks redefinition of \Re

To replace the Gothic type real-part operator by a plain 'Re', the following works for me: \documentclass[a4paper,11pt,twoside,fleqn]{report} [...] \usepackage{amsmath} \usepackage{mathtools} ...
1
vote
0answers
35 views

defining a new infix command

This question kind of already exists here: How to write infix macro/newcommand? But I'm not looking for a way to divide using an infix command, which I know there already exists a command for. I'm ...
4
votes
1answer
22 views

Passing escaped special characters for use as a URL through macros

From an earlier question on Escaping special characters for use as a URL, using \string to escape the special URL characters in the second example works great: \DefineMyFormatLinkParameters{% ...
4
votes
1answer
69 views

Escaping special characters for use as a URL

If a url contain special characters (~ and #) using it as \href{http://people.brunel.ac.uk/~mastmmg/ssguide/set_work.html#4_32}{people.brunel.ac.uk} works just fine. But, I would like to have macro ...
5
votes
3answers
74 views

Issue: string manipulation with links inside

I have defined a new command \openintro which I call at every chapter of my work. This command basically constructs a lettrine sentence, like the image below (don't bother with text style): ...
2
votes
2answers
85 views

Patching local commands defined within other macros

This is the follow-up - question, respectively the main cause which led to the (yet) unanswered question here: \xpatchcmd defines macros when applied to undefined commands I tried to patch some ...
7
votes
2answers
436 views

How can I write a macro which enters math mode when called in text mode but when called in mathmode doesn't break?

I'm using the package braket for my physics notes, and this speeds things up a great deal but I'm constantly writing \ket{\psi} or \bra{\psi}, and because this specific pair of bra and ket appears so ...
12
votes
1answer
146 views

\DeclareTextSymbol and \DeclareTextCommandDefault in contrast to standard \newcommand et al

In this answer egreg used the macros \DeclareTextSymbol, \DeclareTextCommandDefault and \UndeclareTextCommand where I had previously (and unsuccessfully) tried a simple \newcommand or \let. Could ...