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

How make \parshape declared inside an environment to apply the next paragraph outside the environment?

I'm trying to do something like the MWE below: \documentclass{article} \usepackage{lipsum} \newenvironment{myenv}{% \parshape = 4 0pt 0.5\textwidth 0pt 0.5\textwidth 0pt 0.5\textwidth ...
11
votes
4answers
119 views

A question about macro matching

Consider the following macro definition, and subsequent invocation: \def\foo #1 #2 \bar{stuff with #1 and #2 goes here} \foo arg1 arg2 \bar The \bar simply acts as the terminator for \foo. This all ...
0
votes
1answer
2k views

Undefined control sequence argument [closed]

\begin{algorithm} \SetKwData{Candidates}{candidates} \SetKwData{Links}{links} \SetKwData{Visited}{visited} \SetKwData{URL}{URL} \SetKwData{TraversalDepth}{traversalDepth} ...
4
votes
3answers
886 views

Misplaced \omit and \multicolumn in \IfEqCase

I have the following code with a command that creates rows for a tabular: \documentclass[letterpaper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{xstring} \newcommand*{\condrow}[2]{ ...
2
votes
2answers
147 views

New operators inside tikzpicture

I am trying to declare a new operator (only using horizontal and vertical lines and labels). By now I used tikzpicture for that with the following code: \newcommand{\newtypeline}[3]{ ...
7
votes
1answer
82 views

I need an hrule, but not when at the top of the page

I have a multi-page document that has many small sections split with \hrule lines. Occasionally a section will end immediately before a page break, and so the next section will begin right at the top ...
5
votes
2answers
130 views

Input Single Value, store 5 different value

My LaTeX code is: \documentclass{thesis} \begin{document} \arttype{5} \end{document} Required Output is: If arttype value is 5: `5thArticle Title-tnins` is need to store in \newcommand ...
4
votes
3answers
117 views

Creating an environment that uses macros

I have a macro that requires some setup code before being called : \documentclass{minimal} \usepackage{color} \begin{document} % some setup code \colorbox{green}{This is green.} % some cleanup code ...
4
votes
1answer
2k views

Questions about algpseudocode

I'm using the following packages: \usepackage{algpseudocode} \usepackage{algorithm} but I don't understand what package is algpseudocode, since I can't find the documentation. I have followed this ...
3
votes
1answer
227 views

Macro that maps a number to pifont ding character

With pifont, the darkened circled number starts from 182. I made a macro that maps \dcircle{1} to \ding{182} as follows. \newcommand{\dcircle}[1]{\ding{181 + #1}} However, \dcircle{1} returns ...
3
votes
1answer
135 views

frontmatter is one column body matter is 3 columns

I would like frontmatter should be in single column (one column). After \maketitle contents should be in 3 columns. How do control in LaTeX class file? My LaTeX file: \documentclass{owns} ...
3
votes
1answer
159 views

How to setup “smart citation commands”?

The biblatex package comes with a bunch of example files. One of them is called 18-numeric-hybrid.tex. It contains the following text: We define a dedicated citation command for online references ...
10
votes
1answer
255 views

How to define commands that do not consume any space

I want to create an environment that generates special tables and graphs. Inside the environment the user should be able to execute predefined commands that either modify the behavior of the final ...
4
votes
1answer
129 views

I need a fully expandable function to expand in an “f” type argument

I really hope that I'm asking the correct question. What I'm actually working on if far more convoluted than what's happening in the MWE here. I think I've narrowed down things to real problem. I ...
8
votes
3answers
229 views

Definitions of mathematical terms and declaration of symbols

When writing articles containing math, I would like to have a way to ensure that I am not using an undefined term or symbol. For instance, I want to use the term "simple algebra" only after I define ...
6
votes
2answers
56 views

Command which uses brackets automatically when applied to more symbols

How can I define a command like *, similar to \newcommand{\astcommand}[1]{{#1}^*} but which, when applied to a single symbol a, gives the output a*, and when applied to multiple symbols, like abc, ...
1
vote
0answers
85 views

How to modify some command (like \begin{flalign}) so I can use it as my own

my first post as every beginner starts with question and later on I will give answers :). OK, I am doing my undergraduate work (to become graduate) in Electrical Engineering and I choose LaTeX as ...
4
votes
1answer
370 views

Exercise enumeration

In order to make it easier to write hand-in assigments, I want to create two environments Subexc and subexc, where I can write the entire exercise down before starting. Subexc is supposed to be run ...
7
votes
1answer
161 views

How do I use commands within tabular definition?

Using commands within tabular definition result in error ! Missing $ inserted. In this case, it is the \, that causes problems when calling the custom command. Same commands work fine outside tabular ...
13
votes
3answers
2k views

Multiple letters without spacing in Math [duplicate]

Is there something I can add to the preamble of my document such that multiple letters without spacing in a Math environment (such as $NP$) do not have extra spacing between them and are not ...
4
votes
1answer
68 views

How to include \index{} in new command (custom macro)?

When I try to used \index{} inside of \newcommand, the entry is made in the index, however, the text no longer appears in the body. How can I achieve a macro for the \index command? ...
7
votes
1answer
4k views

Defining New ShortCuts in TexStudio

This is not about new macros like \newcommand, \def and others. This is not about autocompletion like using .cwl (in TexStudio) This is also not about using shortcuts for predefined commands that are ...
8
votes
1answer
260 views

Use lualatex to create macros

I used the following in the past and it worked: \documentclass{minimal} \usepackage{luacode,luatextra} \begin{document} \begin{luacode*} MyVal=123 tex.print("\\def\\MyVal{"..MyVal.."}") ...
17
votes
3answers
852 views

Conditionally Remove Brackets

I'm trying to create a command with an optional argument using \newcommand{\Af}[1]{{\mathbf{A}_{(#1)}} where the argument is a number. However, I'd like that if no argument is given the bracket ...
6
votes
1answer
113 views

Commands with Capital letters in their name

A topic that appear over and over is to explain the difference about commands such as \operatorname vs. \DeclareMathOperator. So far I've seen discussions about using one or the other, but no one ...
7
votes
1answer
139 views

Macro finding a forgotten \command

I do not know if this question has more to do with the editor I use (which is LaTeXShop, on Mac) or some clever LaTeX package, but I am typesetting some notes for a course and I would like to ...
5
votes
1answer
2k views

\newenvironment where all text is typewriter (like \texttt)

I'd like to have an environment that encloses all its content into the typewriter font as \texttt{} does. However, I do not want to use \texttt{} but an own environment, e.g. \begin{allintypewriter} ...
5
votes
1answer
77 views

newcommand which computes something

I would like to have a command which executes a simple division of numbers. This \newcommand{\mylen}[1]{1.0 / #1} just prints 1.0 / 3 when invoked as \mylen{3} and not the desired 0.33333. What do I ...
15
votes
2answers
393 views

A \(re)newcommand that does not care if a command is already defined

Does there exists a version of \newcommand, something like \extranewcommand{\foo}{bar} which does defines \foo to stand for bar regardless of whether \foo has been previously defined? Of course, if ...
2
votes
0answers
202 views

Put ampersand (&) inside conditional [closed]

I'm trying to make a command that formats the alternatives of a test. Can I put an ampersand after each alternative? (I call my tabular command out of this command, and I want to put each alternative ...
5
votes
3answers
183 views

How can I remove outer brackets without expanding content?

I'm trying to use pgfkeys to collect information that will be passed to a clist. But, I'm not able to get this to work correctly. It seems that I'm getting brackets around the list and is prevent ...
9
votes
1answer
150 views

What can and can't occur as macro argument?

The documentation of the environ package says The advantage to using environments is that their contents is not treated as a macro argument, so there are less restrictions on what can exist ...
4
votes
1answer
199 views

Making a class to generate colored tables with a predefined layout

This is a follow-up question in which I asked how to define classes with \newcommands into \newenvironments, and I had some good answers to this particular issue. However, the problem that I have ...
4
votes
1answer
354 views

\itemize vs. \begin{itemize} not behaving as expected

I want to write a wrapper macro for an itemize environment. I would like to use the enumitem package (though the MWE here doesn't use or need this package). The problem is the parameters that I'm ...
2
votes
1answer
217 views

Hooking in before \documentclass

In the consequence of a previously asked question (Is it possible to hook in after options have been processed in a certain package or class?) I had the idea of a hook that adds code even before ...
3
votes
1answer
62 views

Is it possible to hook in after options have been processed in a certain package or class?

In other words: Is it possible to scan the input stream of a .sty or .cls file (without using Perl) for \ProcessOptions\relax and nest some given code afterwords? (The filehook or etoolbox package ...
5
votes
1answer
61 views

tex using the wrong macro

Out of curiosity I tried to weave the bibtex.web source code and compile the resulting bibtex.tex with tex. I got some errors which led me to investigate; I'm sure my confusion stems from incorrect ...
14
votes
1answer
205 views

Typesetting of digits in groups of two

Consider the following example: \documentclass{article} \usepackage{oldstyle} \begin{document} \textos{12345678} \end{document} I would like a command that group the digits in two and puts a \, ...
4
votes
1answer
96 views

Testing for “emptiness” (theoretical consideration)

Consider the following theoretical problem: Sometimes, in LaTeX one wants to do the simple test if a macro is empty, e.g. \def\foo{% This is... \ifx\baz\@empty Sparta! \else a pony farm. \fi } ...
1
vote
1answer
57 views

redefined math command printed with error [closed]

why is my command \mercur shown with error, but the default \mercury command without? MWE: \documentclass[10pt,a4paper]{article} \usepackage[latin1]{inputenc} \usepackage{wasysym} ...
11
votes
2answers
259 views

Print small TeX code verbatim and render it

To write some documentation, I would like the ability to define a command such as \showcase{x^{y}\in\Omega} which expands to something roughly equivalent to \verb|x^{y}\in\Omega| & ...
3
votes
2answers
75 views

Handling _ in macros

So I have a big number of figures with _ in their names. I want to include them in my document and I want to print the filename for the file. Something like: \foreach \dataset in {CPD, EPAFHM, FDA, ...
9
votes
3answers
159 views

Problem with ^^<HEX>

I have small problem with ^^<HEX>. If I have a <HEX> part of the ^^<HEX> in the macro \def\attemp{<HEX>}, I cannot write ^^<HEX> as ^^\attempt or ...
11
votes
1answer
128 views

Size of indices (sub- and super- scripts)

I've been looking around for a way to change the size of indices (all through the manuscript). I found a lot of stuff, which could work, but I refuse to use without understandind. (See for example ...
9
votes
2answers
199 views

Is it possible to use $ as a macro delimiter?

Experimenting with macro definitions that use strange delimiters (see e.g. this or this question), I thought it would be fun to have a macro that takes an argument of the form "a/b" and turns this ...
3
votes
2answers
82 views

How can I replicate a command name as an argument?

I've searched for but not found an answer to this. I am using two layers of \newcommands to create symbols inline with text, using \includegraphics. (It's for music symbols.) At present, I have this ...
3
votes
1answer
287 views

Creating a list of 'stacks' leads to 'Argument of \@firstoftwo has an extra }'

the title may be confusing, but I'm not sure how to name it better. This current question is the result of my other ones, and the hints I got from users in this board. Steven B. Segletes helped me ...
11
votes
1answer
265 views

Make a command to mark a text and class them for text analyze

Sorry for my English, I'm French and it's my first post on this forum, but I'm a frequent visitor of this forum, thanks for all ;) My problem is this : I'm working with transcriptions of 35 ...
4
votes
1answer
143 views

Add optional argument to the caption to get into figure list entry

I would like to add the optional list entry, which is used for a listoffigures, also to the caption. In this basic example: \documentclass{scrreprt} \usepackage{caption} \begin{document} ...
2
votes
2answers
107 views

Why can’t I define a command with \renewcommand?

I try use boolean expresion which it has been shown on my MNWE: \documentclass[12pt, b4paper, twoside]{scrbook} \usepackage[log-declarations=false]{xparse} \usepackage{xltxtra} ...