Tagged Questions

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

How can I redefine the chapter command to display additional text below the title?

I'm relatively inexperienced with Latex. I'm using the Memoir class and I've been trying to develop a custom chapter style based on Danie Els' BlueBox style (the source for this is given on page 46 of ...
8
votes
1answer
194 views

How to rename an existing command?

I would like to know if renaming a command is possible in LaTeX. For instance, could I change the \section by \sec ? I read that some people used something called "alias".
6
votes
1answer
97 views

testing parameter values with \ifx

Let's say that I would like to redefine \@seccntformat so that whenever the section counter is printed, it is prefixed by Section, but other counters should no be changed. Here is my failed attempt: ...
0
votes
0answers
16 views

Include SVG aligns/centers different when used with “newcommand”? [duplicate]

this is my first post in this forum, but i have been here a thousand times, enjoying the high-quality answers to often also good quality questions. So i try my best to also provide all needed ...
4
votes
1answer
45 views

How to know if page is empty

Looking for macro to know if the current page is empty , and opening new page if were not as well. Is there any idea to do that? example in this MWE \documentclass{article} \usepackage{tikz} ...
2
votes
1answer
57 views

macro to showcase newly defined macros

I have the following MWE which takes an argument and prints it verbatim. I have obtained the code from this answer. \documentclass{article} \makeatletter \newcommand{\myverb}{% \begingroup % ...
1
vote
0answers
25 views

Macro for textinput without any formatting [duplicate]

Is there a LaTeX macro that just compiles whatever I type into it? Something like \text or \textnormal. I want to display a LaTeX code inline without any formatting, but don't want to escape ...
2
votes
1answer
114 views

Modify the @tufte@margin@float environment to automatically align floats

The Tufte classes provide the @tufte@margin@float environment which is used for tables and figures, but its result it's not automatically aligned with the text. The \marginnote command provide a ...
0
votes
0answers
30 views

Output command arguments for spellchecking

I have a longer tex file which contains text in different languages. The languages are highlighted in different colors, e.g. {\color{blue} some text in french } {\color{red} some text in ...
2
votes
0answers
69 views

What is the meaning of \+ in doxygen-generated latex?

When compiling a software reference manual with doxygen and latex output, I get the following error: ! Undefined control sequence. l.2 ... Modular System for Shelves and Coasts (M\+ ...
4
votes
1answer
74 views

text inside tikz node which can skip to an other

I would like to put text in a mini page with fixed length inside a tikz node using \sbox , if the text skip a specified length (10cm) it will be saved in an other \sbox and used inside a tikz node ...
8
votes
2answers
91 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
293 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
149 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 ...
3
votes
2answers
224 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
196 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
61 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
87 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
114 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
157 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
77 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
40 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
109 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
53 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
48 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
91 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
126 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 ...
9
votes
3answers
203 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
290 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
126 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
135 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
169 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
98 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
51 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
216 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
96 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
2answers
86 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
39 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
114 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
154 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
81 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
86 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
115 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
46 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
149 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
74 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
83 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
536 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
141 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
92 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): ...