{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)

3
votes
1answer
40 views

How can I use adjustbox in \sectionmark?

I want to use adjustbox in \sectionmark but it doesn't work. Is there a work-around for this? \documentclass{book} \usepackage{blindtext} \usepackage{adjustbox} \usepackage{fancyhdr} ...
1
vote
2answers
109 views

Semantic indications in LaTeX

I'd like to include in my LaTeX code some form of indication that certain words are keywords, or that a phrase is a quote, or that another phrase is an example, etc. Where can I find a list of inbuilt ...
4
votes
2answers
100 views

Remove macro's functionality via a regular expression

I want find all \textbf in my .tex file and delete it, together with it's argument braces {}. For example, I want to change: \textbf{text} to text \textbf{text \textit{textbis}} to text ...
1
vote
0answers
40 views

\ref to \label in other document?

I have a repository with one document, but I think of splitting it into two documents, whereas I want to cross-reference from one to eachother. Is there a way, to "rewrite" \ref to automatically ...
2
votes
1answer
41 views

Define reusable content — preferably in the body or else in the header

I am writing a document where name of a person A will appear at multiple places section A. Similarly, name of person B will appear at multiple places in section B, etc. Is there any way by which just ...
1
vote
0answers
38 views

Make References title bold in apa6 class document (using natbib) [duplicate]

I'd like the References title to be bold. My MWE is below. If you comment-out the \usepackage{natbib} (and following line) the problem doesn't occur. Assuming natbib is causing this, I thought adding ...
2
votes
1answer
35 views

Using argument command as argument without brackets

I would not be surprised if this has been asked before, but my searches did not yield any results. Neither would it surprise me if this is not possible without doing some really dangerous hacking of ...
4
votes
1answer
35 views

Aliasing, with or without argument?

What is the correct way to alias a command to another one? \newcommand*{\keyword}{\emph} or: \newcommand*{\keyword}[1]{\emph{#1}} Apart from the fact that the second is more explicit, is there ...
4
votes
1answer
48 views

Content summaries - sections

I'm currently writing up my thesis and I have a section "content summary" in my introduction section. This gives an indication to what each section contains and is about. At the minute, each chapter / ...
4
votes
0answers
39 views

Variable Input/Output node using a new command

How can I create a variable input/output node using a new command as in the following picture Say for example, I know that the node will have n inputs and m outputs, which I enter the name as an ...
4
votes
2answers
48 views

How to store the definition of a command? Or, how to disable locally a command?

what? I would like to "store" the definition of \includegraphics into \something so that the following logics will work: % the following line is what I am looking for store(\includegraphics, ...
0
votes
0answers
51 views

Macros for the subscript and spacing

I would like to define the command A\!\!_B\!C in a math mode as a macros, and I am using the following: \newcommand{\cmp}[3]{#1\!\!_#2\!#3} Unfortunately I get an error that there are {} missing. ...
7
votes
3answers
115 views

How to horizontally align rotated text in a table?

I am trying to horizontally align text that has been rotated in a table. I want the rotated "Lorem Ipsum" and the rotated "Lorem Ipsum & Lorem Ipsum" text to be horizontally centered in the cell. ...
5
votes
2answers
219 views

how to redefine environments like \begin{xxx} … \end{xxx}

I'm translating some text that use the comment package, it's usage seems like that: \begin{en} ... some English text \end{en} \begin{zh} ... corresponding Chinese text \end{zh} By using ...
1
vote
2answers
56 views

amsmath, vec and if not working together

I am trying to define some macros in which I need an "if" which test contains an argument of the macro. The issue arises when this argument is \vec{<arg>} and the amsmath package is loaded. Here ...
16
votes
2answers
153 views

Why is unskip not working here?

I'm trying to define a macro to be used as follows: \usepackage[normalem]{ulem} \newcommand{\thesis}[1]{\uline{\ignorespaces #1\unskip}} % underlining required by school - I know, I know % later... ...
4
votes
0answers
85 views

Conditionals—do something, if a given command is being used in the document

Is it possible to have a conditional that allow us to do something if a given command is being used in the document? For example for the \part command would be: ...
4
votes
2answers
130 views

How do you make the underscore active in environments but preserve its orignal use in math mode?

I'm experimenting with creating a formatting shorthand package. I want to use the underscore to delimit an underlined text span, like so some text _underlined text_ more text Simply making the ...
1
vote
1answer
37 views

shaded frame not working in TexStudio

I'm using TexStudio 2.6.6 and MikTex portable. I'm trying to build the example CV from here: http://www.njohnston.ca/2008/12/latex-cv-template/ The problem is that I get a lott of "Undefined Control ...
2
votes
1answer
33 views

outline package, how to change enumeration style?

I'm working with the outlines package. I want to change the 2nd level enumeration style from small letters ( a b c ) to small roman letters ( i),ii),iii)... ). In other words, I want to exchange the ...
4
votes
1answer
319 views

Hacking - Memorize a command before reimplement it

Here is a small code. \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{menukeys} \begin{document} \keys{Ctrl+Alt+C} \keys{BUG} \keys{\return} \end{document} ...
17
votes
1answer
370 views

Newcommand: What cannot be done?

It is not the first time I tried to create a new command unsuccessfully. Some things I found out did not work (getting "undefined control sequence" or other errors). Use a quote-endquote argument. ...
4
votes
1answer
61 views

List all macro calls

Assume I have a big document that uses several macros, say \AAA, \BBB, etc., through the whole document. Is there a way that I can have a list of all these macros in the final pdf? I want to repeat ...
8
votes
4answers
130 views

Problem with csname macro expansion

I want to dynamically define some macros that essentially create a list of \refs. I seem to be able to define these macros but then I am unable to print them. Here is my M(non)WE: ...
8
votes
1answer
115 views

Looking for \providelength

I need a macro similar to \providecommand. \providelength{\lengthName}{0.5cm} should give me a new length if it is not existing yet. I would like to use the macro to set standard values for a ...
7
votes
2answers
245 views

Macro: Replace all occurrences of a word

I repeatedly use certain keywords such as var in my document which I highlight using \src{var}. This is cumbersome to type and gets annoying after a while. Repeatedly search-and-replacing var to ...
0
votes
0answers
34 views

All available 1-letter LaTeX commands [duplicate]

I want to define shortcuts for often used commands in LaTeX, but without redefining any existing commands (using \newcommand). I want my commands to be short, but \a, \b, \c, and several others are ...
7
votes
1answer
76 views

Parallel paragraphs across odd and even pages

I have a document where paragraphs should be aligned across odd/even (left/right) pages. I use the following code from this answer (courtesy of Nicola Talbot) \documentclass[12pt]{scrbook} ...
2
votes
0answers
51 views

tikz command fails after .cls file change

The following tex content is a part a tex file which is added to main file with command input. With a new .cls and some other unrelated changes, tex isn't compiling with error message of ! Package ...
4
votes
0answers
34 views

Is there a good reason to define helper macros second? [duplicate]

As a mathematician, my training is to define my terms before I use them. As a computer programmer, I recognize that there are sometimes good reasons to call a method/function/procedure before its full ...
1
vote
1answer
24 views

Create a command that outputs the same markup with minor changes

I need to insert the following markup multiple times in my document: \documentclass[a4paper]{book} \usepackage[italian]{babel} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{fullpage} ...
1
vote
1answer
72 views

Defining a custom symbol by path in TikZ

I want to define a 2-to-1 multiplexer symbol, defined by this path: (0,0) -- (1,-0.5) -- (1,-1.25) -- (1.3,-1.25) -- (1,-1.25)-- (1,-2) -- (0,-2.5) -- (0,-1.75) -- (-0.3,-1.75) -- (0,-1.75) -- ...
17
votes
2answers
252 views

How can I redefine my macro to accept a charcode instead of a character?

I recently posted this answer to How to highlight all words of the form [0-9][A-Za-z0-9]* immediately following an equal sign?. It works, but it suffers from (a lot) of code duplication. What I have ...
3
votes
1answer
34 views

\ifmmode check in section caption

To assure the correct usage of newcommands which only shall be used in mathmode, I have introduced a mathcommand, which checks mathmode by \ifmmode. Now I want to use such a mathcommand in a section ...
7
votes
1answer
93 views

What does “@” at the beginning of a command name mean? [duplicate]

The answers to this question mention commands such as \@author and \@director, and latex.ltx is full of them. However, when I use \@author in my document, it just outputs the word "author". What does ...
8
votes
5answers
394 views

Special case for last element with \foreach

I want to create a function that generates a list of equation references from a comma delimited input list. e.g. \erefs{eq:first, eq:second, eq:third} \erefs{eq:first} yields, the following: ...
10
votes
2answers
123 views

Save counter value inside command?

I'm trying to automatically generate commands based on the value of a counter: \documentclass{article} \newcounter{count} \newcommand\generator[1]% {% \stepcounter{count}% ...
2
votes
1answer
63 views

Macro for pgfplot cycle list entry

I'm trying to define multiple cycle lists based on macro variables. The reason for this is that I need more than one list and I want to be able to change the appearance quickly while keeping the ...
1
vote
1answer
79 views

Newcommand returning a boolean value

I'm using etoolbox. How can I create a new command that returns a boolean value? For example if I create the following command: \newcommand\ifkeyempty[1]{ \def\novalue{\pgfkeysnovalue}% ...
3
votes
2answers
120 views

Issue with \\ in custom command

So I'm trying to make my own command to make matrices less painful My current command is: \newcommand{\mat}[2]{ \left(\begin{array}{#1}{#2}\end{array}\right)} with the intention to use it as: ...
4
votes
3answers
57 views

cellspacebreak macro

(I am rolling my own little system to take my LaTeX file and convert it to reasonable HTML and Epub. I have run into the following problem.) I would like to keep my tabulars very simple. There are ...
9
votes
1answer
100 views

Storing environment arguments by \immediate\write

As I have stated already in other questions I am writing a problem/solution package. There are many of them, for sure, I have made much progress, using it in 'everydays' productivity for my needs, but ...
1
vote
0answers
18 views

Custom environment shorthand for multiple environments [duplicate]

I am interested in doing something like the following. \documentclass{article} \usepackage{amsmath} \newenvironment{customeq}{\begin{equation}\begin{split}}{\end{split}\end{equation}} ...
2
votes
2answers
50 views

How to properly modify certain behaviors of a document class?

This is a real example of what I'm trying to understand by this question: I'm rewriting my CV using europecv and one behavior that I don't like, is titles of personal information: Lets say, I want ...
3
votes
1answer
46 views

How to define a function with optional key-value arguments [duplicate]

I have setup a function called quickfigure which has the purpose of inserting a centered image with a one-line command: \newcommand{\quickfigure}[2] { \begin{figure}[H] \centering ...
2
votes
1answer
68 views

Change font family locally (using package with limited scope)

I want to be able to use small caps for chapter headings. According to Using \textsc{} within \section{} CM default font does not support small caps so I need to use: \usepackage[T1]{fontenc} in ...
2
votes
1answer
79 views

LaTeX new command with no argument

I write some presentation with beamer. In the middle between each section I create some frame for outline content. But because presentation too long, I used \includeonlyframes{current} command to ...
3
votes
3answers
131 views

Append to an argument

I have a command that receives some argument, like: \newcommand{\myappend}[1]{ \ifthenelse{\equal{#1}{aaaBB}}{\dothis}{\dothat} } Assume that the argument is 'aaa'. How to append (inside the ...
5
votes
0answers
62 views

Convert sequence to table [duplicate]

I'm trying to write a macro that converts a sequence to a table. The following code works fine: \documentclass{article} \usepackage{expl3} \begin{document} \noindent \ExplSyntaxOn \seq_new:N ...
3
votes
2answers
195 views

Extract first letter of each word in a sentence

I don't know if already exists a question like this, but after 20 minutes I haven't found one. There are similar ones, like How to define a command that bolds the first letter of each word in the ...