{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
1answer
62 views

tikz: How to pass a list as a parameter of a tikz macro and use it in a foreach inside the macro

I am trying to write a macro for drawing some graph, but since the content of each node is specific it has somehow to be passed as a list to the macro. Here is an example of an ad-hoc code of what I ...
2
votes
1answer
53 views

Font size of an argument which may be omitted

(It is possible that this question has been asked before; I don't know how to search for it.) Suppose I have: \newcommand{\example}[3] {#1} {#2} {#3}} And I know that I want the font size of the ...
4
votes
1answer
96 views

Strange preamble for a thesis or this is normal?

I have a somewhat strange template that I should use for submit my dissertation for the speciality. I put the code as a minimal working example for you to see: ...
4
votes
1answer
91 views

How to avoid the compilation of some of my newcommands in latex

I'm writing an exam for my students, and have defined 3 commands to insert spaces with \dotfill permitting them to write their responses: \rep,\replarge, \repLarge for short and large responses: ...
3
votes
1answer
100 views

LaTeX: macro templates

Often at the end of astronomical papers there is written that it was created using the AAS LaTeX macro v5.2 . Do I understand this right that one can download such a template with all preamples at the ...
1
vote
0answers
21 views

Preprocessing code for cross-compilation of two different projects?

I have two different projects, which are the LaTeX code for English and Greek for the same book. Does LaTeX support preprocessing code (without using any external tools) that would allow two ...
2
votes
1answer
416 views

Potential problems from passing macro arguments to \verb

I've been working on a command that will typeset snippets of code within a paragraph. I'm aware of listings and company, but I want something that will just typeset the code verbatim and also allow ...
2
votes
1answer
67 views

How to show multi-choice answer key at the end of the document?

I want to show the answer keys at the end of the (multiple-choice) exam page. I have a bank of questions and answers (always the first answer in the bank is assumed to be the right choice), and some ...
2
votes
1answer
70 views

Commands to help indexing

I want to have easier ways to index large texts such as thesis, reports, books. I found lots of posts here asking for some magic tool to do that automatically. And as far as I could realize from the ...
1
vote
1answer
22 views

Report class section hierarchy duplication with alternate prefix format OR multiple documentclass references in discrete environments

In a large thesis style document being prepared, there are certain parts (latex hierarchy \part{}) that are being treated as insertions of previously prepared work. This may include articles or ...
3
votes
1answer
68 views

A question about using a \renewcommand to adapt a package

This article is a sub-question of: Cross-referencing on two kinds of end-footnotes (separated and with different coloured numbers) Hi, I am trying to adapt a package called parnotes (which can be ...
2
votes
2answers
74 views

Similar Structured Macros

I am currently using the macro, \def\<#1: #2: #3\>{\langle #1\;:\if#2\empty\else\;#2\;\fi:\;#3\rangle} Taken from: http://ctan.org/pkg/tex-ewd. And I would like to make another similar macro, ...
5
votes
2answers
48 views

Passing return values from one \newcommand to another \newcommand?

I would like to know how to pass out the output of one \newcommand to the input of another \newcommand. For example: \newcommand{\bra}[1]{$\langle{#1}|$} \newcommand{\comm}[2]{$ ...
2
votes
1answer
80 views

Textsize changes with \par

This is somehow a follow-on post of Newline linespacing problems within a table cell. What i want to do is having different font styles in one table cell. I've learnt so far that a local size change ...
5
votes
5answers
125 views

Nested \def's causing \inaccessible error

I tried out a - at least in my eyes - very simple way to capitalize words: \documentclass{article} \begin{document} \begingroup% \obeyspaces%\catcode`\ \active \def {\space\MakeUppercase}% Hello ...
2
votes
1answer
48 views

Calling macro fails with error \inaccessible

I am trying to define a macro which I will include in a class definition. For the time being I put the macro definition in the normal document. Compiling the following document fails. ...
3
votes
2answers
2k views

Where to type command line to compile Latex on Ubuntu? [closed]

(Please forgive me if this question is so simple or looks stupid) I want to run Latex on Ubuntu. It is said that we use similar commands as those used in Windows OS, (e.g. pdflatex file.tex, ...) ...
2
votes
1answer
81 views

Create a command for a different font

I'm pretty new to Latex and I am writing my thesis. I would like to use a command that I can essentially change the font of a few words in-line or separate (like an equation). I have computer ...
0
votes
0answers
80 views

True `macros' in (La)TeX [duplicate]

When using \newcommand and the like, LaTeX seems to create a new box for the content (I'm probably observing things wrong). For example, I have \newcommand{\p}[1]{\ensuremath{\left(#1\right)}} in my ...
5
votes
2answers
85 views

Inserting Macros in argument of \sindex[]{} aren't expanded

I've to build an individual register with \sindex[]{} from the splitxdx package from an outside generated TeX code. The call name of people with two firstnames is sometimes put in braces, sometimes ...
5
votes
2answers
40 views

How to insert a dashed line over a bigwedge symbol so that the dashed line behaves like overline would?

I want to insert a dashed line over symbols \bigwedge and \bigvee in such a way that it looks exactly like a solid line over the same symbols. I know how to insert a solid line over those symbols (for ...
2
votes
1answer
58 views

Supply commands to be executed upon leaving math mode

I have an important macro \textmacro that can only be invoked in text mode. I would like a macro \mathmacro such that issuing the command Some text $a^b\mathmacro c^d$ more text is automatically ...
2
votes
2answers
77 views

using \def for my own \newenvironment

I am trying to write a command that shortens for a command for writing proof. At the moment, I used to use \newenvironment{proof}% {\textbf{Proof:}}% {\begin{flushright} $\blacksquare$ ...
2
votes
1answer
49 views

creating custom function for images

I've been going through some LaTeX today and I'm wondering how to get a custom function that will display images. What I wanted to do was have custom functions for each chapters images that would ...
2
votes
1answer
50 views

Converting strings to counts

I'm reading in a number (as text) from the aux file and I want to do a numerical test (\ifnum) on it. I can to it using \setcounter and \value, but I really don't want to create a counter just to do ...
0
votes
0answers
16 views

! Missing \endcsname inserted. Because of Turkish [duplicate]

When I try to build and view my .tex document. I get the error. I have viewed at the topics like the problem. How can I fix the problem ? Thank you for all appreciated answers. Error: ! Missing ...
1
vote
1answer
60 views

Multiple problems with custom commands and fancyhdr

I have kind of a multiple part question. I am making a class file for a standard operating procedure class file. This includes the need for revision control flags. I am trying to make a custom ...
6
votes
2answers
118 views

Macros that can lead to double periods at end of sentence

Suppose that a document makes a heavy use of one of the abbreviations PhD, Ph.D., DPhil and D.Phil., and for the sake of consistency the author decides to define a \PhD macro and use it whenever they ...
3
votes
2answers
307 views

Defining macros in LyX

I am having a problem defining a script that I got as a macro in LyX (or even making it "work" in LyX). The script I have is the following: ...
6
votes
3answers
155 views

Special behavior if optional argument is not passed

I am looking to define a command (actually, an environment, but that shouldn't matter for the purposes of this question) that does some default behavior, and if an optional argument is passed, does ...
4
votes
1answer
90 views

Macro take argument without wrapping in brackets?

I want to make macro which do not require curly brackets to accepts an argument. Lets invent an example. Say I want a macro which accepts an optional argument f and an argumentx: \dd[f]{x} And ...
2
votes
1answer
61 views

Is there any way to create extensions for latex

I wonder whether or not there is a platform to create extensions for latex. ANd if there is, here is the extension I want: My main language is turkish. And turkish is agglutinative language. For ...
18
votes
11answers
537 views

Storing an array of strings in a command

I want to store three strings in a variable \mydata like the following: \storedata\mydata{one}{two}{three} Then I want to extract the first/second/third string in the following way: ...
44
votes
7answers
13k views

Isn't there any other way of doing double quotes in LaTeX besides `` + ''?

The standard way of writing quotes and double quotes in LaTeX is with `` and '', but I find them quite ugly. Isn't there something similar to \emph{}, but for quotes? I mean something like ...
2
votes
2answers
41 views

Custom environment for second-level items not vertically aligning properly

While writing a document with lots of enumerate environments, I wanted to add a little subset, 1. So the item is here — and the inset is here Which I did pretty easily. However, when I ...
1
vote
1answer
108 views

LyX command(s) to insert WYSIWYG horizontal line, for keyboard shortcut

Using the menu entry Insert > Formatting > Horizontal Line I can insert a WYSIWYG horizontal line into a LyX document. I want to figure out the internal command(s) used to do this so I can set up a ...
27
votes
2answers
737 views

How do I debug pgfkeys?

I'm sure if you're reading this question you are already familiar with my love for pgfkeys. However, it is absolutely impossible to debug: \tracingmacros is a total mess, with every key expanding to ...
1
vote
1answer
61 views

Refers to a node on a chemfig inside a node in a tikzpicture. Macro definitions

Consider the minimal example: \documentclass[12pt]{article} \usepackage{tikz} ...
4
votes
1answer
96 views

Change positioning of *all* figures

I'm designing all the figures for a book and I wanted to be able to change the positioning [hbtp] of all of them with one macro/command. A solution in which I could override the existing positioning ...
10
votes
5answers
1k views

Defining `$$$ $$$` to align

I would like to define $$$ \zeta(s) = \dfrac1{1^s} + \dfrac1{2^s} + \cdots $$$ as a short hand for \begin{align} \zeta(s) = \dfrac1{1^s} + \dfrac1{2^s} + \cdots \end{align}` How should I go ...
3
votes
1answer
29 views

Macro expansion and href with hyperlink

I have very simple question I hope! I am writing a book on MPASM (PIC) assembler and there will be very many similar links to programs, hex files, videos etc. These will be enclosed in a standard ...
4
votes
0answers
62 views

What might be wrong if one defines \newcommand{\1} [closed]

Coincidentally, I download a beamer theme from online source (Feathertheme.sty). When I try to add some packages to my own beamer file (say \usepackage[xy]{xy}), I see that it goes wrong, the ...
2
votes
0answers
12 views

Macros for image, coimage, and cokernel [duplicate]

I work in LyX. There's a default macro for the kernel: \ker which has nice spacing if I put something after it, compared to \text{ker}. I'd like to have macros with the same nice spacing for the ...
31
votes
4answers
6k views

Defining commands/abbreviations that contain numbers

I tend to use \newcommand to define macros for symbols I use often, e.g. \newcommand{\hankel}{H^{(1)}_0}. One inconvenience of this approach is the fact that command names cannot include numbers. ...
4
votes
2answers
46 views

Custom command to represent $L_1$ metric distance that works both inside and outside math mode

I'm trying to write to define \ds(a,b) so that it results in $||a - b||_1$. This should also work inside a math environment e.g. as part of an inequality statement, but I should be able to use it in ...
1
vote
1answer
40 views

Automatically enclose \glt line from gb4e in \enquote{}

How can I automatically enclose the \glt (\trans) line in gb4e's interlinear glosses in context-aware quotation marks with \enquote{} from csquotes? \documentclass{article} ...
2
votes
1answer
38 views

changes package for peer reviewed journal: hide authors and convert 'replaced' to 'added'

I'm using the changes package to keep track of any changes I ( and my co-authors ) made for a peer reviewed journal. Meaning, in response to each of the reviewers' comments, we are using a new author ...
5
votes
3answers
130 views

Delimiting-a-macro-with-itself-chain

Reading this question and the answer of @Werner made me think about if it is possible to have chains of self-delimiting macros like \XX abc \XX def \XX xyz or lets say \begin{someenv} \XX abc \XX ...
5
votes
2answers
2k views

Vertical addition and multiplication and long division

Is there in existence packages that recreate the following environments: Some of the above have been discussed like in the How to present a vertical multiplication but what I am interested in is if ...
9
votes
1answer
234 views

“Flatten” macros prior to sharing LaTeX file

Is there a way/an existing tool to process a LaTeX source document such that for a given list of macro definitions (using \newcommand), calls to those macros are replaced by their expanded version? ...