{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
6 views

text inside tikz node which can skip to an other

I would like to put the text in a mini page with fixed length inside a tikz node using \sbox , if the text skip the specified length it will be saved in an other \sbox and used inside a tikz node in ...
8
votes
2answers
62 views

Package csquotes does not seem to work within a mdframed box defined via a macro

If I define a macro which uses a mdframed box, this seems to disable csquotes (red box). But using mdframed directly (i.e., without defining it via a macro), then the csquotes package can do its job ...
8
votes
1answer
273 views

Does \Twoheadleftrightarrow exist? How to write my own?

I'm a LaTeX newbie. I am writing a document in which I need to have a two-headed bidirectional arrow. Two-headed like \twoheadleftarrow, bidirectional like \leftrightarrow. Is there any package that ...
10
votes
2answers
127 views

Passing command output as a parameter to the other command

I created some kind of switch statement with a help of \ifthenelse command. Now, I would like to pass its output to another command. In my example I want to colorize each sentence with a color ...
2
votes
2answers
83 views

redefine starred command \section*

with \usepackage[explicit]{titlesec} I have defined \section like \titleformat{\section} {\ttfamily\Large\bfseries\color{red}} {\thesection} {1em} {#1} i want to redefine the starred ...
6
votes
2answers
176 views

macro that deletes whatever symbol follows after the code and leave no space

How would the following macro X be defined in TeX? word in previous sentence?\macroX . Next sentence gives output identical to word in previous sentence? Next sentence The motivation: a period ...
4
votes
1answer
44 views

Arbitrary positioning in math mode without size restriction

In the MWE below, are all general methods, of achieving arbitrarily shifting of symbols up or down or left or right in math mode, represented? If yes, that is the answer. If no, what good methods are ...
3
votes
2answers
49 views

Problems in expansion of a setcounter macro (Use of \csname doesn't match its definition)?

Followup to Split the reference counter for any numbered item (like with subequations) : I was trying to make a generic subanything macro, and I fail miserably - see MWE below for what I get as error ...
6
votes
1answer
76 views

Execute a command automatically for each Page

my code save groups inside environment topr and topl to two sbox , the command \border draw a frame devided into two parts and put in them the two sbox , here is my MWE \documentclass{article} ...
6
votes
1answer
104 views

Are (La)TeX macro/command names restricted to ASCII code characters (letters)?

Perhaps this question has been asked already, but my search efforts were unsuccessful. Is it necessary to have ASCII characters (i.e. letters basically [a..z,A..Z], special characters such as \( etc ...
0
votes
1answer
43 views

Graphics: Moving Images and aligning with text

So currently I have this code written out: \begin{figure}[ht!] \includegraphics[width=60mm, scale=0.3]{titanium-distillation-vessel.jpg} \caption{Argon Vessel, containing TiCl$_{4}$ and Mg} ...
3
votes
1answer
30 views

Replacing some macro tokens in a list before \write ing

I'm trying to hack a bibliography package (amsrefs), and fall into the following problem. I'm trying to convert the amsrefs format back to .bib files. This doesn't quite work, because strings get ...
7
votes
2answers
95 views

convert a \newcommand to \newenvironment

I have defined a command as follows \newsavebox{\textsix} \newcommand{\bottomr}[1]{\sbox{\textsix}{\parbox{11cm}{\begin{flushright} #1 \end{flushright}}}} which save the parameter (text) of the ...
4
votes
1answer
48 views

Command with semi-arbitrary characters

Is there a way to define TeX commands with names containing (almost) arbitrary characters, like :, -, _, numbers etc., perhaps even spaces? These are the characters I shall need apart from the ...
2
votes
1answer
44 views

Problem with \edef and CJK

In the following code, it seems that using \edef with CJK contents may fail. (I used pdflatex, UTF8 encoding.) \documentclass{article} \usepackage{CJK} \begin{document} \begin{CJK*}{UTF8}{bsmi} ...
4
votes
2answers
46 views

new command using math mode sub index bug

I have defined the following command \newcommand{\gsubselector}[2]{$s_{#1,#2}$} and I'm calling it from a document in the following way: ... \gsubselector{a,i} : \gsubselector{b,j} there is ... ...
2
votes
1answer
110 views

Command to gray words

I would like to create a macro in LaTeX to have the following effect (gray parts) on some text: I would like to have something like \gray{Hello} which puts brackets and grays the text. Can someone ...
8
votes
3answers
172 views

Is it safe to “renewcommand” \SS? (Which packages use \SS command?)

I've tried to set \newcommand{\SS}{\mathcal{S}} in the preamble but I've discovered that this command is already defined. So, I tried native command on my code and I've found that it is a "simple" ...
7
votes
1answer
278 views

What generically CANNOT be compiled inside an equation environment?

Certain macros or whole environments which are themselves not equations, like whole tikz diagrams can be placed in the equation environment and compile. For example Diagram displayed as an equation ...
8
votes
0answers
90 views

How to pass a LaTeX argument verbatim to lua?

I would like to pass an argument verbatim from LaTeX to lua including LaTeX commands and end of line characters. The example below takes care of the former issue, but not of the latter. Is there a ...
4
votes
1answer
89 views

How to declare a macro with a variable argument list?

I am looking for a macro with two optional arguments and tried the following code: \documentclass{tufte-handout} % \usepackage{xparse} \usepackage{lipsum} \usepackage[demo]{graphics} ...
6
votes
1answer
155 views

Defining macros with arguments

With newcommand I can define customized command like \ABC. Is there any way to define a command with arguments. For example I want \brat{A}{B} be the same as [\![A,B]\!].
3
votes
1answer
96 views

How call several commands by one commands?

If you want to write an algorithm, you have to write three commands to initialize a writing environment. \usepackage{algorithm} \usepackage[noend]{algpseudocode} \begin{algorithm} % no.1 ...
1
vote
1answer
30 views

BibLaTeX' \citefield not expanded as expected

I have run into what looks like a macro expansion issue. Consider the following example: \documentclass{article} \usepackage{hyperref} \usepackage{biblatex} \begin{filecontents}{expprob.bib} ...
7
votes
2answers
194 views

How can I use Chinese characters (or more generally, Unicode characters) as a macro name?

\documentclass{article} \usepackage{CJKutf8} \usepackage{ruby} \renewcommand\rubysep{.05ex} \renewcommand\rubysize{0.2} \newcommand\神{\ruby{神}{かみ}} \begin{document} \begin{CJK}{UTF8}{min} \神 ...
4
votes
1answer
73 views

Command \color already defined

I have the following code in my latex command . \newcommand{\color}[1]{\lceil (#1+2)^2/2\rceil} After that I have inserted the following command for insertion of code in LATEX documents . ...
4
votes
1answer
53 views

Using set list with pgfplotstable

I am trying to create a new column in a table using the set list option, but it will not expand the list when stored in a macro. I've tried \expandafter in various locations with no joy so far. ...
2
votes
1answer
27 views

How to define macros for paths to be used by biber?

I want to use a shortcut to define the paths of my bibtex files and I'm using biblatex and biber. I would like something like: \addbibresource{\myPath{biblio.bib}} I tried in several ways i.e. ...
5
votes
2answers
109 views

General way to split a line by a rule of thumb and displaying results

The following is to construct illustrations for concepts of frequency of a properly sampled outcome if any such frequency exists. Doing such illustrations is tedious and liable to error by hand ... so ...
5
votes
3answers
147 views

Trim braces from macro content

I'm having macros with a content which may or may not have extra curly braces. I want to trim the extra braces but without expanding the rest of the content, if possible. The following code shows the ...
0
votes
1answer
42 views

Mathjax can't render some of LaTeX basic commands [closed]

Sorry this is probably a very silly question as I'm too new to LaTeX. Mathjax has issues rendering basic LaTeX commands like /xspace and /ensuremath There are some custom macros in my LaTeX files, ...
8
votes
1answer
71 views

TeX-FAQ: Non-letters in macro names - special-command generator

I had a look at TeX-FAQ on Non-letters in macro names and tried to implement the approach #2. It looks like I'm missing something. When trying to refer later to the new commands the result is not what ...
5
votes
2answers
101 views

How to allow # in \newcommand without \# or another way to defer processing of section of code

I am trying to defer processing of some latex code. This works, \documentclass[a4paper,final,11pt]{article} \usepackage{hyperref} \begin{document} here comes a reference ...
4
votes
1answer
43 views

How do you define a command to select nested groups?

Assuming a pair structure (2-tuple) is defined using groups {{<tokens1>}{<tokens2>}} is it possible to define a command \first#1{...} (and \last#1{...}) taking the surrounding group as ...
2
votes
1answer
98 views

Why is newcommand not working?

I am quite new to latex and try to understand the \newcommand command. Since (at least in texmaker which I am using) \autocite does not seem to feature autocompletion and automated display of my ...
5
votes
1answer
68 views

What's special about \: in the implementation of \pgfutil@ifnextchar

There is the following snippet of code in pgfutil-common.tex (with a very similar snippet in pgfmathutil.code.tex`): {% \def\:{\global\let\pgfutil@sptoken= } \: \def\:{\pgfutil@xifnch} ...
5
votes
1answer
69 views

How does \path, and the like, parse its argument?

I'm really curious whether someone would care to take the time to explain how to create macros which work similar to some of the macros in the pgf/TiKz bundle. What I'm particularly interested in is ...
7
votes
3answers
517 views

Defining 3*(2^4) complex macro at once

An Automata can be 1- or 2- ways, With Several Heads or a Single head Deterministic or Non-deterministic With a stack or not That makes 2^4 = 16 possibilities. However, for each combination, I'd ...
3
votes
2answers
109 views

How do you define one macro with arguments inside another

How do I define a \newcommand (or in LaTeX 3 a \NewDocumentCommand) which itself defines a \newcommand with arguments. For example in \documentclass{article} \begin{document} \newcommand{\test}[1] { ...
2
votes
1answer
65 views

How do you define a command for use in a tikzpicture environment?

I want to define an environment for the tikzpicture environment which defines tikz specific commands. Here's an abbreviated example for a UML environment which defines a \Class command): ...
3
votes
1answer
61 views

Using \newcommand works fine in LaTeX, but when I use htlatex the line of text that \newcommand was supposed to insert gets moved to the next line?

So, I'm trying to write lines of code explaining to new students where to find different files and directories. Because the classname changes on a yearly basis I set up a \newcommand to make changing ...
1
vote
1answer
41 views

ifthenelse to ignore a section

I am writing a textbook which has a student version and a teacher version. I did this: \newboolean{teach} \setboolean{teach}{true} ...
8
votes
3answers
516 views

Without any built-in looping macro, can we just use a recursive macro to get a-b-c-d-e?

Without any built-in looping macro, can we just use a recursive macro to get an output of a-b-c-d-e? \def\aaa #1{#1-\aaa} \aaa abcde % expected result : a-b-c-d-e \bye Edit: Probably the best way ...
15
votes
1answer
181 views

\def two macros with same name, but different argument syntax

Is it possible to have macros with the same name, but different “syntax”? E.g. we have the primitive \font which could be seen as having 3 arguments(a. without size information; b. giving the ...
5
votes
1answer
114 views

Defining a LaTeX macro with optional arguments as keywords inside square brackets

I want to define a macro to insert pictures in figures, called \centeredfigure, which I am hoping to use the same way as \includegraphics. In \includegraphics, all optional arguments are given in the ...
8
votes
2answers
89 views

How to use \edef to wrap an existing macro with @inmatherr?

I have a handful of existing macros that I want to wrap in some custom processing. Here's an example of the kind of thing I'm aiming to do: \makeatletter \let\olddag\textdagger ...
8
votes
4answers
541 views

How can I create lambda expressions?

It's common for packages to accept one- or two-argument macros as transformations of some element, and it's at least common for me for these to be one-offs that don't deserve a permanent name—or at ...
5
votes
1answer
66 views

newcommand about array

$ \left\{ \begin{array}{l} a+b=c\\ c+d=e \end{array} \right. $ I define a macro command for it. \newcommand{\curleq}[2]{\left\{\begin{array}{#1}{#2}\end{array}\right.} When I type ...
1
vote
0answers
36 views

indexing with sed using less brittle \gls and \acs and \index commands

I'm writing a book for which I produce sections for glossaries, acronyms and index entries using the glossaries, acronym and makeidx packages on a template derived from the Springer book template. To ...
0
votes
0answers
40 views

How to create another styling format like \emph

I read how to change \emph and changed it to \DeclareTextFontCommand{\emph}{\bfseries}. Now I want to create another command like \secondstyleformat which I can configure aswell. Such a format could ...