{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
2answers
1k views

How to add source information at bottom right corner of a figure in beamer?

I am inserting several figures into my beamer presentation that I did not create myself. Therefore I would like to add some source information with just a command, e.g. \PassOptionsToPackage{demo}{...
1
vote
1answer
187 views

How to add \thanklessauthor to a KOMA Script document?

Well I'm working with a document in KOMA Script and I tried to use the \thanklessauthor command that I found in the code of the Sample book of Tufte-book class. First I thought it was a plain TeX ...
3
votes
1answer
305 views

Defining custom direct and inverse limits

I would like to define custom direct (a/k/a inductive) and inverse (a/k/a projective) limits, as used in category theory, for example. (Not the limit as used in calculus.) In other words, I'm looking ...
1
vote
1answer
86 views

\newcommand Error Either Way [closed]

I have two documents, both starting with \documentclass{article} \usepackage{Macros} \begin{document} where Macros is my own style file. There are no other packages or definitions in either of the ...
6
votes
0answers
372 views

Automatic dropcaps for the first letter of a chapter

I'm in the process of writing a LaTeX style for thesis dissertations, and would like to automatically transform the first word of a chapter to dropcaps. This is trivial to do manually using the ...
4
votes
1answer
50 views

Macro with optional arguments into arguments of another macro

I just want to pass as an optional argument, a macro with an optional argument. If you look at the minimal exampel below, if I use [scale=1] in the optional arguement of the new macro it does not work....
5
votes
2answers
193 views

New primitives and grammar for replacing horrible \expandafter

Time and time when I am trying to read or write some macros, I'm always frustrated by lots of \expandafters inside them. Why don't we add some new primitives and grammar into TeX engines to make ...
2
votes
1answer
82 views

How can I add title like command?

I am making a poster where I edited an existing style \setbeamertemplate{headline}{ \vskip4.5cm \hskip14cm \mbox{% \begin{minipage}[r][][c]{\dimexpr\textwidth-15cm\relax} ...
13
votes
6answers
969 views

Show only two year digits

How can I insert two digit year string? I know that the command \the\year inserts four digit year string. I tried using \twodigit\year, but it also returns four digits. I guess I need some kind of ...
4
votes
3answers
93 views

Print a macro I created in a package

Based on the answer I received to Print a short title in the header, I've created the macro \handoutheader in a .sty file I use as the template for my conference presentations. \newcommand\@confname{}...
0
votes
0answers
25 views

Custom sectioning below subsubsection : generic macro ? [duplicate]

I would like a to create a custom sectioning, the depth of which can be... very large. I am currently using this macro to create the subsubsubsection environment. \makeatletter \newcounter {...
7
votes
2answers
181 views

What internal command(s) does \hspace call?

I know that (by \hspace vs. \hspace*) the command \hspace* calls the internal commands \vrule width 0pt \nobreak \hskip 1cm \hskip 0pt plus 0pt minus 0pt but which command(s) does \hspace use? Is ...
13
votes
2answers
301 views

ifx, macros and grouping

I do not understand how \ifx interacts with macro definitions. Here is a minimal example: \def\a#1{\b} \def\b#1#2{[#1:#2]} \a ABC The output is [B:C], as expected. If I change the definition of \a ...
0
votes
0answers
69 views

Multiple references with letter

I want to group the range of references together with letter of the alphabet (i.e. [A.1-A.5] instead [A.1][A.2][A.3] or [A.1, A.2, A.3] and I know that I should use \usepackage{cite} for it. Documment ...
4
votes
1answer
82 views

Unescape command parameter

I'm using docutils to generate LaTeX files, with custom roles for using latex specific commands in the rst files. My problem is, that docutils automatically escapes underscores in the parameters of ...
2
votes
1answer
130 views

How to reuse common data elements for multiple macros?

I want to use macros to present different combinations of data elements from the same data set more than once in the same document. For example, it is easy to summarize the elements from Data Set A ...
6
votes
1answer
197 views

Customizing enumerated lists with tikz prints enumi instead of number

I'm trying to make an enumerate list that has the numbers inside a colored circle. For the circles I'm using the tikz package and the color package. I define a circle in the preamble and then I ...
5
votes
1answer
75 views

Macro that checks for the beginning of a line

How can I add a new command that differentiates between the first word of a line, and any other case? For example, the macro \etc for printing "etcetera" if its the beginning of the line, otherwise, ...
5
votes
1answer
54 views

How to create new accented character in mathmode that works with superscripts and under scripts

I'm trying to write a macro that would yield in math mode the placement of a character (for example, *) above a variable (here, x) with superscripts (^) and underscripts (_) similar to what LaTeX does ...
7
votes
1answer
676 views

custom hatching pattern : arbitrary direction of hatching

For a kind of mathematical illustration, consider the case where several distinguishable hatchings, all black and white, and precise direction has meaning, are required. I give a simple example of a ...
3
votes
2answers
2k views

“Undefined Control Sequence” error despite \newcommand definition!

I have installed texlive full package: I use TeXmaker and this is a code where I want to draw a grid as in tikzpicture. I want to just call the \gridkar function defined below. So I defined it in \...
3
votes
2answers
81 views

Compiler Error when Creating a Macro/Environment

I'm trying to create a new command or environment or something to format what is essentially a section, but it needs to have it's own counter. I would like to not use any of the \section \subsection ...
7
votes
1answer
303 views

Problem with underscores in \newcommand

I am currently writing my thesis and I have each chapter as a separate project- I've been told I should join them up but I don't want to for now as I would find it overwhelming. I'd like to be able to ...
1
vote
3answers
141 views

Parse csv-list, function with >1 parameters as callback

In my texts I have to deal with lists, whose items need to be formatted seperatly, i.e.: \funktion[3][]{T}--\funktion{S}--\funktion[3][7]{D}--\funktion{T} In \funktion which leads to \emphsubsup the ...
7
votes
1answer
255 views

Defining a new command works selectively

I have just created a new command that will print text in bold and blue using the following syntax \newcommand{\blue}[1]{\color{LHCblue}{\textbf{#1}}} My full code is \documentclass[slidestop,...
1
vote
1answer
4k views

“There's no line here to end” in custom command

I am working on creating a resume in LaTeX and have defined a command that allows me to input my work experience. The only problem is that whenever I try to use an itemized list, as seen below, I get "...
4
votes
2answers
177 views

Using forcsvlist with macros that take more than one argument

I'd like to compact this code sample with \forcsvlist (provided by the etoolbox package). \newcommand\mycmd[2]{ \pagestyle{#2} \csname tit#1\endcsname \cleardoublepage } \def\DOtitlepages{ \...
3
votes
3answers
126 views

\input{} as argument for \inputgraphic{}

I got a question very similar to this post (\includegraphics{\input{|shell command}}) which unfortunately hasn't been really answered. The aim is to make a command that invokes a python script to ...
4
votes
2answers
120 views

Add content from an external file to the input tokens for parsing

I have a possibly very long sequence of tokens which is parsed by a macro. I would like to be able to read parts of this sequence from external files, if this is possible. I made up an MWE for this ...
2
votes
1answer
106 views

How can I apply a custom-defined theorem environment to nested theorems *only*?

In a previous thread, I asked about the possibility of defining a custom theorem environment whose QED symbol would be a boxed version of the theorem's name/number/label. There, I was graciously ...
9
votes
2answers
724 views

How to use \csname, \expandafter, \csuse, \@namedef …?

I have the following package \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{mypkg} \providecommand*\@mycmd{No {\MakeUppercase Mycmd} defined} \newcommand*\Mycmd[1]{\renewcommand*\@mycmd{#1}} \newcommand*...
2
votes
2answers
94 views

Defining New Environments using a Command

I would be able to do something like the following: Instead of having the following, where I repeat the same code many many times: \documentclass{article} \usepackage{enumerate} \newenvironment{...
0
votes
1answer
369 views

Why does LaTeX macro spells \LaTeX{} (which requires Shift) and not \latex{}? [closed]

Why does LaTeX macro spells \LaTeX{} (which requires 3x presses and 2x releases of Shift) and not \latex{} (which can be typed w/o Shift)? Same about \TeX{} macro of course. The current spelling ...
2
votes
1answer
88 views

How to check if a macro from <some package> is used in a document?

I was interested in some method to check if any macro from some package is used into a .tex file. So, for example I would like to specify a package (say it's fontawesome) then point to a .tex file ...
4
votes
3answers
188 views

Newline is not working with parbox and usebox

I would like to save data to a savebox (or any other storage element) in iterations. At the end I would like to put each datapoint in a framebox and then in a frambox container with a given width. ...
0
votes
0answers
31 views

Can't make unit vectors with greek letters [duplicate]

I have this command \let\oldhat\hat \renewcommand{\vec}[1]{\boldsymbol{\mathbf{#1}}} for making bold vectors. And have this commands here \newcommand{\uvec}[1]{\hat{\textbf{#1}}} \newcommand{\ihat}...
9
votes
2answers
119 views

Why is the character following this macro-defining macro gobbled up?

I have the following plain Tex code: \def\xx{ABC} \def\temp #1 {\def\tempii{#1}} \temp\xx a b c \tempii\tempii I expect to see the following output: a b c ABCABC But I actually see this: b ...
3
votes
1answer
51 views

Add newcommands to a package with arguments

I want to make a package that has a bunch of commands that I define in all of my Problem Sets. I'm running into an issue where the compiler does not recognize commands that I define that have an ...
2
votes
1answer
119 views

How to load user defined content to be used in a template?

I'm writing a template which uses the report class and customizes the typesetting with several packages. I'm defining some data in a separate user-data.tex file which is loaded just after ...
5
votes
1answer
323 views

destructive code by style file

I'm making a certain program, which is calling LaTeX. I'm thinking that this program can include only one style file. My question is "can we write destructive code in style file?". For example, can ...
11
votes
2answers
221 views

Macro to add starred version of command

How can one write a meta-macro that adds a starred version to a command? Intended use would be along the lines of \newcommand\foo[1]{foo is #1} \addstarred\foo[2]{foo is #1, bar is #2}
0
votes
3answers
530 views

Redefine \chapter and \chapter* with \cleardoublepage inside .cls-file

\newcommand{\Chapter}[1]{{\let\cleardoublepage\relax\chapter{#1}}} works fine. How can I do the same for the stared (*) version inside a .cls-file? (Could be interesting for others: Is there any ...
3
votes
1answer
100 views

macro with optional argument in eforms textField

This is my code: \documentclass{article} \usepackage{polyglossia} \usepackage[useui]{eforms} \newcommand{\myvalue}[1][]{Testvalue #1} \begin{document} \textField[\ui{value={\myvalue[foo]}}]{...
5
votes
2answers
132 views

Matrix of values as parameter for a macro

This is my code: \documentclass{article} \usepackage{polyglossia} \usepackage{forloop} \newcommand{\values}[2]{ \ifcase#1% \ifcase#2% value a% \c% value ...
6
votes
2answers
240 views

Space between commandname and argument-braces

Simple question, maybe duplicate but can't find it. I see some people (especially novices) writing something like \textbf {text} %or \frac {1} {2} It looks not good with the spaces between the ...
1
vote
2answers
119 views

Macro indent line even on newline

I'm new to creating my own commands (this is my first) and I can't seem to achieve what I set out to do. My current command looks like this \documentclass{article} \usepackage{xparse} \...
27
votes
3answers
827 views

How to make a command completely empty / invisible / non-existent?

I have a command like \newcommand{\todo}[1]{#1} which I sometimes replace by: \newcommand{\todo}[1]{} In terms of spacing/whitespace, the behavior of the "empty" command is as follows: Test. \...
5
votes
3answers
213 views

Defining a command with variable number of primes

I want to construct a new command which allows me to write somthing like: \env{3} Which would then expand to: σ''' I.e. a sigma with the specified number of primes. I however have not been able ...
3
votes
2answers
110 views

Page break after each section with title

I'd like to have there be a page break in between each section, just like in this question, but I'd also like there to be no page break prior to the first section (that is, between the title and the ...
7
votes
2answers
219 views

Define a macro changing category code of number sign (namely \makenumbersignletter)

Under Typesetting hashtags with natural syntax Joseph Wrigh ask me to ask a new question: In LaTeX, \makeatletter is short for changing the category code of @. But something like \def\...