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

6
votes
2answers
152 views

TeX/LaTeX: Macro for getting a length as number

I would like to write a macro getlengthin to get a length or dimen as floating point number in a specified unit. Here is what I have created so far: \documentclass{article} ...
5
votes
2answers
53 views

Help with a \newcommand not working with autonum

I am writing my thesis. To write math formulas I created the command \eq as follows. \newcommand{\eq}[1]{ \begin{equation} \begin{split} #1 \end{split} \end{equation}} However, now I want ...
6
votes
4answers
170 views

\newcommand with optional argument

The idea is define a command as \newcommand{\mycommand}{This is the official long name} and I use it as \mycommand several times in the document. But sometimes I would like a short name, something ...
9
votes
2answers
113 views

How to define a command that produces a different savebox depending on the argument

I'd like to define a sequence of saveboxes \fooA, \fooB, etcetera, in a style file and introduce a command like \newcommand{\foo}[1]{....} which produces \usebox{\fooA} if the argument of \foo is 1, ...
3
votes
1answer
61 views

Bold paragraph symbol in redefined paragraph command

I have redefined the paragraph command, so that a paragraph symbol is pronted along with the number. \renewcommand{\theparagraph}{\S \arabic{paragraph}} ...
2
votes
2answers
129 views

New command, load multiple images

I have to load multiple images to my thesis. Its about 320 pictures to shortcut this, I want to make a new command to load them more flexible. My basic idea was to create a new command with multiple ...
6
votes
2answers
369 views

Draw rectangle with two foci (like an ellipse)

How can the code be improved? Can I make the variables local? \documentclass[12pt,tikz,border=5pt]{standalone} \usetikzlibrary{calc} % this is from % ...
3
votes
1answer
36 views

(e)def and BibLaTeX

I'm trying to understand why the following code does not work: \documentclass[12pt]{book} \usepackage{polyglossia} \setdefaultlanguage{french} \setotherlanguage{english} ...
0
votes
2answers
110 views

How to create labels and references automatically in LaTeX?

I have defined two custom macros: \translation{ORIGINAL}{TRANSLATION} \printtranslations The first macro prints out the translation and puts the original and the translation into a list. The list ...
2
votes
0answers
37 views

Automatically return list of all uses of a command, without repeats e.g. \compound using chemstyle

I'd like to automatically generate a comma separated list of all occurrences in my .tex file of a particular command. Specifically, I want to ensure the correct numbering of chemical structures using ...
6
votes
2answers
117 views

Enhanced fill-in-the-blank document

I am about to improve my lecture slides from last semester. Specifically, I would like to add a fill-in-the-blank option. I found this code suggestion (from here): \documentclass{article} ...
8
votes
3answers
224 views

Preferred way to define a text command (with or without a parameter)

Which of the following declarations is preferred when defining new textual macro's in latex \newcommand*{\dosomething}[1]{\textbf{#1}} versus \newcommand*{\dosomething}{\textbf} textbf is just ...
4
votes
2answers
107 views

Explanation of the usage of a particular new command to personalize it

A guy had a problem personalizing his ToC, and you helped him suggesting to use this lines: \newcommand{\mychapter}[2]{ \setcounter{chapter}{#1} \setcounter{section}{0} \chapter*{#2} ...
5
votes
2answers
116 views

macro with \newcommand using foreach to create tree in tikZ

In the two examples below I use the same code in two different ways. Why is it that TikZ gets confused about who the parent node is when using the macro \department{name dept}{list of subdepts} ...
3
votes
1answer
43 views

Custom .sty warning on specific command

I am writing a custom .sty file and I notice that it can break if a certain command, native in Latex, is called. I would like to throw a warning to the user and say "Don't use this command!". I know ...
5
votes
1answer
158 views

Macro in Tex Programming

I am confused whether the below macro is for section or what? If yes can anybody help me to explain this piece of code \def\Section #1 \par { \bigbreak\vskip\parskip \need 1.5 in ...
1
vote
1answer
94 views

Reset a renewcommand

I have found a Resumé template in Latex. I would like to change the following part of the template but my knowledge of Latex is not that extended. % Every \item can be followed by one or more ...
6
votes
6answers
251 views

command for printing only what has been specified as A or B

Suppose I have a document like the following: % !TEX TS-program = lualatex \documentclass{scrartcl} \newcommand{MyCommandForPrintingOnly}{...} \newcommand{MyCommandForSpecifying}{...} ...
0
votes
0answers
39 views

How to change the \namedata of examdesign?

I know a little about TeX or LaTeX. I am just making an math exam for my students and I am using examdesign because it randomizes the questions. But, my problem is that these students are High ...
4
votes
2answers
90 views

Some text or symbol after \item element

I want add some text after of each element \item. For example, I defined a new command \newcommand{\qitem}{\item?} %For the list of questions \begin{enumerate} \qitem Some question \end{enumerate} ...
3
votes
1answer
41 views

savelowerto option from tcolorbox fails inside a wrapper command

I am experimenting a little bit with a favorite package of mine: tcolorbox, the following code is cut out/reduced from a larger 'project', cut down to a command \newcommand{\splitmycontent}[2]{% ...
6
votes
2answers
180 views

How to make latex parse `x` as an argument of a macro definition instead of `#1`

When I define a mathematical function for plotting in pgfplots or pstricks I usually to it in the following way: \def\f(#1){(#1)^3 + 3*exp(#1)} just as suggested by Jake in his answer to a ...
3
votes
2answers
151 views

width of \parbox issue

I am using a template for a CV in LaTeX and I am facing certian difficulties in getting things aligned properly. The code I am referring to is \newcommand{\NewEntry}[3]{% Define a command for each ...
7
votes
3answers
338 views

Expanding macros within \csname

I have some macros that expand to some text but when used together they should expand to something completely different. In this example: \foo -> x \bar -> y \foo\bar -> Hello World Doing it with ...
4
votes
1answer
69 views

Definition with roman counter value

Is it possible to write a definition with a counter value? I have many definitions with a Roman numeral: \def\abcI{} .. \def\abcII{} .. \def\abcIII{} .. But this is not possible: ...
2
votes
1answer
58 views

Font size of an argument which may be omitted

(It is possible that this question has been asked before; I don't know how to search for it.) Suppose I have: \newcommand{\example}[3] {#1} {#2} {#3}} And I know that I want the font size of the ...
1
vote
0answers
37 views

Preprocessing code for cross-compilation of two different projects?

I have two different projects, which are the LaTeX code for English and Greek for the same book. Does LaTeX support preprocessing code (without using any external tools) that would allow two ...
2
votes
1answer
124 views

tikz: How to pass a list as a parameter of a tikz macro and use it in a foreach inside the macro

I am trying to write a macro for drawing some graph, but since the content of each node is specific it has somehow to be passed as a list to the macro. Here is an example of an ad-hoc code of what I ...
4
votes
1answer
109 views

How to avoid the compilation of some of my newcommands in latex

I'm writing an exam for my students, and have defined 3 commands to insert spaces with \dotfill permitting them to write their responses: \rep,\replarge, \repLarge for short and large responses: ...
2
votes
1answer
100 views

How to show multi-choice answer key at the end of the document?

I want to show the answer keys at the end of the (multiple-choice) exam page. I have a bank of questions and answers (always the first answer in the bank is assumed to be the right choice), and some ...
2
votes
1answer
54 views

Duplicate and modify section hierarchy

In a large thesis style document being prepared, there are certain parts (latex hierarchy \part{}) that are being treated as insertions of previously prepared work. This may include articles or ...
3
votes
1answer
88 views

A question about using a \renewcommand to adapt a package

This article is a sub-question of: Cross-referencing on two kinds of end-footnotes (separated and with different coloured numbers) Hi, I am trying to adapt a package called parnotes (which can be ...
2
votes
2answers
87 views

Similar Structured Macros

I am currently using the macro, \def\<#1: #2: #3\>{\langle #1\;:\if#2\empty\else\;#2\;\fi:\;#3\rangle} Taken from: http://ctan.org/pkg/tex-ewd. And I would like to make another similar macro, ...
5
votes
2answers
85 views

Passing return values from one \newcommand to another \newcommand?

I would like to know how to pass out the output of one \newcommand to the input of another \newcommand. For example: \newcommand{\bra}[1]{$\langle{#1}|$} \newcommand{\comm}[2]{$ ...
2
votes
1answer
94 views

Textsize changes with \par

This is somehow a follow-on post of Newline linespacing problems within a table cell. What i want to do is having different font styles in one table cell. I've learnt so far that a local size change ...
2
votes
1answer
83 views

Commands to help indexing

I want to have easier ways to index large texts such as thesis, reports, books. I found lots of posts here asking for some magic tool to do that automatically. And as far as I could realize from the ...
5
votes
5answers
164 views

Nested \def's causing \inaccessible error

I tried out a - at least in my eyes - very simple way to capitalize words: \documentclass{article} \begin{document} \begingroup% \obeyspaces%\catcode`\ \active \def {\space\MakeUppercase}% Hello ...
5
votes
2answers
96 views

Inserting Macros in argument of \sindex[]{} aren't expanded

I've to build an individual register with \sindex[]{} from the splitxdx package from an outside generated TeX code. The call name of people with two firstnames is sometimes put in braces, sometimes ...
5
votes
2answers
72 views

How to insert a dashed line over a bigwedge symbol so that the dashed line behaves like overline would?

I want to insert a dashed line over symbols \bigwedge and \bigvee in such a way that it looks exactly like a solid line over the same symbols. I know how to insert a solid line over those symbols (for ...
2
votes
2answers
89 views

using \def for my own \newenvironment

I am trying to write a command that shortens for a command for writing proof. At the moment, I used to use \newenvironment{proof}% {\textbf{Proof:}}% {\begin{flushright} $\blacksquare$ ...
2
votes
1answer
57 views

creating custom function for images

I've been going through some LaTeX today and I'm wondering how to get a custom function that will display images. What I wanted to do was have custom functions for each chapters images that would ...
0
votes
0answers
16 views

! Missing \endcsname inserted. Because of Turkish [duplicate]

When I try to build and view my .tex document. I get the error. I have viewed at the topics like the problem. How can I fix the problem ? Thank you for all appreciated answers. Error: ! Missing ...
3
votes
1answer
102 views

Converting strings to counts

I'm reading in a number (as text) from the aux file and I want to do a numerical test (\ifnum) on it. I can to it using \setcounter and \value, but I really don't want to create a counter just to do ...
2
votes
1answer
71 views

Supply commands to be executed upon leaving math mode

I have an important macro \textmacro that can only be invoked in text mode. I would like a macro \mathmacro such that issuing the command Some text $a^b\mathmacro c^d$ more text is automatically ...
6
votes
2answers
134 views

Macros that can lead to double periods at end of sentence

Suppose that a document makes a heavy use of one of the abbreviations PhD, Ph.D., DPhil and D.Phil., and for the sake of consistency the author decides to define a \PhD macro and use it whenever they ...
4
votes
1answer
166 views

LaTeX: macro templates

Often at the end of astronomical papers there is written that it was created using the AAS LaTeX macro v5.2 . Do I understand this right that one can download such a template with all preamples at the ...
7
votes
3answers
184 views

Special behavior if optional argument is not passed

I am looking to define a command (actually, an environment, but that shouldn't matter for the purposes of this question) that does some default behavior, and if an optional argument is passed, does ...
4
votes
1answer
117 views

Macro take argument without wrapping in brackets?

I want to make macro which do not require curly brackets to accepts an argument. Lets invent an example. Say I want a macro which accepts an optional argument f and an argumentx: \dd[f]{x} And ...
1
vote
1answer
89 views

Multiple problems with custom commands and fancyhdr

I have kind of a multiple part question. I am making a class file for a standard operating procedure class file. This includes the need for revision control flags. I am trying to make a custom ...
2
votes
1answer
66 views

Is there any way to create extensions for latex

I wonder whether or not there is a platform to create extensions for latex. ANd if there is, here is the extension I want: My main language is turkish. And turkish is agglutinative language. For ...