{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
2answers
84 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
37 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
2answers
72 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
47 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 ...
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 ...
2
votes
1answer
45 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 ...
2
votes
1answer
54 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 ...
6
votes
2answers
117 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 ...
2
votes
0answers
64 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 ...
6
votes
3answers
152 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
89 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 ...
1
vote
1answer
59 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 ...
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 ...
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 ...
18
votes
11answers
524 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: ...
4
votes
1answer
95 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 ...
3
votes
1answer
28 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
58 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 ...
4
votes
2answers
45 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 ...
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 ...
1
vote
1answer
60 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} ...
2
votes
1answer
36 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 this document fails: ...
4
votes
1answer
27 views

How to create a minimal working example for verbatim use in macro definition with cprotect?

cprotect can be used to use verbatim in a macro definition according to the package specification. Just like everything else in the world that doesn't provide an example it doesn't work in real life ...
3
votes
1answer
67 views

Macro for image including

I was wondering if there is a work around, or better way, to include images. I am using a simple macro that helps me: My main.tex \documentclass{article} \usepackage{graphicx} ...
5
votes
3answers
128 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 ...
3
votes
1answer
42 views

newcommand: boldface is extended to next character

I am using a newcommand like this \newcommand{\gen}{\textbf{P1}\xspace} and it works just fine. However in the text the boldface is always extended to the next character. For example lorem ipsum ...
2
votes
1answer
37 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 ...
4
votes
2answers
85 views

How to implement a macro for normal ordering of operators?

I am looking to typeset the normal ordering symbols :O: commonly used in quantum field theory in a way that makes them easily discernible from regular colons, especially the 'defined as' symbol :=. ...
4
votes
1answer
16 views

\if leqno or reqno: command to check whether left or right eq. Numbers were set

I am defining my own command and need to check, which mode the user has set, whether reqno or leqno. Is there a way to do this?
3
votes
1answer
50 views

Correct superscript spacing for new mathbin

I redefined the \div command so that it's U+2215 aka ∕, but for some reason when I use it as a superscript the spacing between this symbol and its numbers is really tight (works fine in displaymode or ...
0
votes
0answers
40 views

Is there a semantic definition command?

Every time I want to emphasize a definition word in a paragraph I need to explicitly state the formatting with \mathbf{<word(s)>}. But I'd like to use a semantic command like ...
2
votes
0answers
61 views

How to make a function inside the tikzpicture behave like outside

I have a makro which generates a structure(rule) and a reference to that structure. It does not behave when inside a tikzpicture. How to make the function robust to reference the structure even when ...
11
votes
4answers
529 views

How to replace text

I'd like to write something like this: \replace{Text should be replaced here, here and here}{here}{Latex} It should output Text should be replaced Latex, Latex and Latex How can this be done? ...
0
votes
1answer
36 views

Expand second argument/counter

I'm currently working on a somewhat automatic way to generate B+ trees. Thus I introduced a new macro to generate the content of a matrix of nodes which should also generate the labels automatically. ...
1
vote
1answer
81 views

Chapter Opener in both Right and Left Side

I would like to get the below chapter opener with back-end Image in my LaTeX file. 1) BackEnd Image 2) Front End Chapter Number and Chapter Title. 3) Yellow Color box is backend and what you will ...
1
vote
1answer
72 views

image height reduce/increase automatically

I have the below boxed environment. The image should place in the marginpar width. When my environment is going long the image should automatically increase upto my enviroment, when is going to low it ...
1
vote
0answers
33 views

Problem with answers using hyperlinks and tbox

I have minor problems with the solutions shown in Hyperlink with answers package I wanted to make a macro which takes solution and exercise as arguments, uses a button like mutual reference, and ...
1
vote
1answer
55 views

How to parse a macro that contains a \let?

My situation is similar to, but hopefully different from How do I ‘expand’ a control sequence \let to a character?, as that question does not admit a positive answer. I want to parse, not expand, but ...
4
votes
1answer
74 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: ...
0
votes
0answers
54 views

Overlay specifications in beamer

I'm trying to create a beamer document class (.cls) with some configurations that please me. But, I ended in this point where a cannot overlay my \newcommand. This code has to collect a few ...
3
votes
1answer
43 views

Using \newcommand to display user input that may contain special characters that need to be escaped

I don't know much about LaTeX right now, but I need to be able to use it to generate dynamic PDF documents using C#. For the most part, everything is cool and works the way I want it to work. ...
1
vote
1answer
37 views

Placing the text under a line in a multiline form

I am typing a form like the following: I want to make a command \newcommand\myform[1]{ *** #1 ***} that will produce the filled-in form with the argument substituted into it. For example, the ...
0
votes
0answers
10 views

Using a comma-separated list for a cycle macro [duplicate]

I am doing abstract algebra and it is rather tiring to have to write \begin{pmat}1 & 2 & 3\end{pmat} or something of that nature every time I want to write a cycle. I was thinking of a macro ...
2
votes
1answer
50 views

How to refer to a word inside a running text as a TikZ coordinate?

Say you have some running text, and you want to be able to refer to some part of that text (like a single word) as a TikZ coordinate in order to, for example, draw edges to that word. What's the best ...
4
votes
2answers
91 views

Processing “List” of “List”

I implemented a short macro that processes a comma separated argument list to format them. So by calling \macroa{ABC, DEF} it will format the text to ABC DEF Now what I would like to have is ...
1
vote
1answer
30 views

Inserting command with optional argument as optional argument Problem

If I define the following two commands: \newcommand{\TestA}[1][]{a^{#1} aaa} \newcommand{\TestB}[1][]{#1} and then call it by $\TestA[\TestB[111]]$ I get the error: "Argument of \\TestB has an ...
3
votes
4answers
93 views

Too many Sums: “TeX capacity exceeded ”

I am a lazy student who writes a lecture in LaTeX. As I need many \sum\limits and \int\limits I tried to overwrite the command \sum\limits so I just have to write \sum. So I wrote ...
3
votes
1answer
35 views

How to pass parametres to an external file included by `\input{<filename>}`

I have a class file to set up agreements. I want to define a command that choose boilerplate text to include using a parameter pass a parameter to the included file to run a test and choose correct ...
3
votes
1answer
75 views

Generating Labels via Macros and loosing \ref{}'s

I want to write a macro which will include labels. When I generate a label with the macro I don't seem to have access to it in the list of Gathered resources provided by Winedt 9. I really want the ...