{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
267 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
76 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
177 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
90 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: ...
5
votes
2answers
160 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
60 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
96 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
334 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
407 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. ...
5
votes
1answer
69 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
171 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
139 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 ...
8
votes
2answers
399 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
99 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
56 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
35 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
33 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} ...
2
votes
1answer
126 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) -- ...
18
votes
2answers
344 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
40 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
109 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
415 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
182 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
96 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
114 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
127 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
60 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 ...
11
votes
1answer
137 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
104 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
63 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
94 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
91 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
141 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
298 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 ...
3
votes
1answer
66 views

Make a command start new line in a list if it is not currently at the end of another list

I am trying to typeset a structured proof as demonstrated by Leslie Lamport in his paper How to Write a 21st Century Proof. In particular, I am trying to typeset Figure 3 (shown below). My code and ...
3
votes
2answers
129 views

How to delete a latex macro in the text but not its argument [closed]

I a newbie in LaTeX. I have the following problem. How to delete a LaTeX macro in the text but not its argument? In particular, how to replace a macro in the text, e.g ...
1
vote
1answer
79 views

Kile, shortcut for most commonly used WORDS?

I'd like to know how to write a *.cwl file for Kile (the LaTeX editor for KDE Debian 7.3) with a list of shortcut words, that I use often such as bcc= because, e--= electrons, h0= holes and so forth. ...
2
votes
1answer
49 views

Variable number of arguments for newcommand, to create a set containing all of them

I am relatively new to LaTeX and I am trying to come up with a way of a creating a command, call it \Set, such that \Set{#1,#2, #3, ... #N} outputs \tau_{#1} = \{ #2, #3, ... #N \} Any help would ...
6
votes
1answer
141 views

Key value options in combination with TikZ

I'm trying to create some TikZ commands that use key value options. Using the following link: How to create a command with key values? I was able to declare some commands, but now I'm stuck. As a MWE ...
2
votes
1answer
65 views

How to remove the word “msc” from the message sequence chart using msc package?

I am using the msc package for creating/drawing message sequence chart. Is there any way to remove the word "msc" from the message sequence chart which appears by default along with the title of the ...
1
vote
0answers
39 views

Bibtex-like macros organising software

From what I gather (I don't use them, and have never actually managed to get it to work - though this is not my issue), bibtex/biber uses a database of references, alongside an ancillary file created ...
6
votes
1answer
301 views

“Double headed” vector

I want to have a double headed vector. I tried \overleftright, but the appearance is all but pretty. I would like to get the same kind of symbol, but with \vec appearance. Is it possible?
5
votes
1answer
104 views

Pattern for \vrule

Is it possible to apply patterns to \vrule possible like dotted? \documentclass{article} \newdimen\le\le=50pt \def\A{\vrule depth0pt height 50pt width 1 \le} \begin{document} \A \end{document}
7
votes
1answer
103 views

Make the pattern of a \def depend on another macro

I would like to set up a macro defined something like this: \def\processline string: #1.#2\relax{\gdef\errorline{#1}} The catch is that the string should be given by the contents of another macro. ...
2
votes
1answer
115 views

Defining a new command whose argument doesn't need braces

I created a \newcommand to allow me to quickly create one-item lists. \newcommand{\itemm}[1]{\begin{itemize}\item #1 \end{itemize}} When I used \item, I don't have to put braces around the text. Is ...
6
votes
2answers
121 views

Text Editor Autocompletion vs direct LaTeX macros

In terms of research paper writing and in general usage, is there a preferred convention for one or the other? I'd like to know simply so that I get into the habit of using the norm as opposed to ...
4
votes
2answers
158 views

How to remove white space before reference?

I'm using \usepackage{cite} to reference bibliography (I'm using bibtex). In general the text is in greek, but bibliography is in english. I'm using babel package, so in order to write in english ...