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

TeXstudio readAllStandardOutputStr seems not to work

I try to insert automatic timestamps into a LaTeX file, to get id's for some items On a windows machine I have got the following macro (JavaScript): %SCRIPT var ...
4
votes
2answers
152 views

create macro to verbatim output of command [closed]

The code \newcommand{\dosomething}[1]{#1 #1} \expandafter\verb\expandafter+\dosomething{blub}+ produces the verbatim-output blub blub. Now I want to create a macro \myverb for the second line, ...
13
votes
3answers
198 views

How to define a new command based on \section with its optional argument?

I've defined a new command called \mysec like the below: ‎‎‎‎‎‎ \documentclass{article} \newcommand{\mysec}[1]{\section{#1}} \begin{document} \mysec[Foo foo]{Bla bla bla} \end{document} But in the ...
0
votes
0answers
124 views

How to check if the selected letter is uppercase or lowercase in a macro?

I'm using Texmaker and want to define some custom macros. The macros shall check if a selected letter is uppercase or lowercase and then replace that letter by a sequence defined in the macro. I need ...
4
votes
1answer
104 views

How to install LawTex on MacTex

I'm relatively new to LaTeX, and I run Mac OSX 10.9.1. I have the latest MacTex, and have used it with relative ease for basic documents. I'm a law student, and I'm required to make a complex document ...
4
votes
1answer
88 views

Redefining environment within a macro

Hel-lo, I am a LaTeX programming newbie. While formatting my document, I found that it will look nice if I can modify the theorem environment (with amsthm package). So I tried the following code ...
1
vote
1answer
43 views

Pre-compiling with a different syntax [closed]

I am looking for a pre-compiler to introduce a customized syntax into LaTeX. Hope that an example will be worth a thousand words: I would like to compile this \thm The sum $ 1+2+3 is equal to ...
2
votes
1answer
59 views

Trouble including graphics from csv file into Pgftable, commands are dissapearing (local maybe?)

I've been trying to add eps graphics with the filename in a csv file. Take a look at the CSV to get an idea of what I mean: ...
2
votes
1answer
102 views

mathjax \sqrt command

I don't if this forum is the right place where post my question, anyway, it concerns TeX. Mathjax seems to create the bar over the argument of \sqrt command as a box with a sequence of very densely ...
6
votes
3answers
102 views

xstring test for numbers within a range

I'm working on a document command that has a variety of optional arguments for different results. I need to add an option that yields 'true' for an optional argument within a range of numbers, for ...
17
votes
2answers
364 views

Why does this simple \ifx test fail?

This should be easy, but I don't understand why the test below fails... I expected Hurrah! to be printed when the \currentchar count reaches 90 (i.e. the character code of Z). There must be some ...
6
votes
1answer
69 views

Expand package option, to make contained character math-active

In an answer to another question of mine, egreg posted code, which activates a character in math mode and gives it the function of \operatorname. Now I want to put this into a package and set the ...
8
votes
2answers
62 views

Indexing: inverting names

I have defined \Index to mark a word or phrase for indexing and also preserve it in text: \newcommand{\Index}[1]{#1\index{#1}} How would I define a macro to invert the index entry? e.g. ...
7
votes
2answers
222 views

Expanding a sequence inside a TikZ path

I am trying to draw a simple path using TikZ, with a custom syntax to specify it. This works: \documentclass{article} \usepackage{tikz} \begin{document} \newcommand{\latticepath}[1]{ ...
3
votes
1answer
136 views

Alternative for \DeclareMathOperator

I'm getting a little tired of defining all my mathematical operators with \DeclareMathOperator. Also it is rarely useful to have them as a macro. On the contrary it sometimes leads to macro name ...
4
votes
2answers
121 views

Build kind of a \includeonlypart for Beamer

(This is a follow-up to a previous question that recieved an answer, but raised a new issue that is presented here) Goal Given that (as far as I know) Beamer doesn't provide a way to include only a ...
9
votes
2answers
129 views

Conditionally use package and define command

I'm creating a class which should define a command if some package is available: \IfFileExists{eforms.sty}{ \usepackage[xetex]{eforms} \everyTextField{\textFont{GaramondNo8}\textSize{12}} ...
7
votes
1answer
113 views

Can I give a function to a label?

I try to create a dynamic way to give labels to my slides in Beamer. \documentclass{beamer} \newcommand{\partName}{blank} \newcommand {\defPartName}[1]{\renewcommand{\partName}{#1}} ...
44
votes
4answers
2k views

What is “expansion”?

I'm relatively new to (La)TeX, but I have a reasonable amount of experience with computational programming languages. Until I began learning (La)TeX, I'd never heard of "expansion"... So, what is ...
7
votes
2answers
159 views

\g@addto@macro appending code using parameter

After a lot of trial and error, I haven't been able to solve the following problem: A simplified version: I want to use \g@addto@macro to add code to another macro wich will use a command of the ...
8
votes
3answers
315 views

How can I add version control info (to footers say?)

I'd like to keep track of revisions to a document and I use version control software for basically everything (SVN by the way, monotonically increasing revision numbers are their own reward). I want ...
3
votes
1answer
72 views

Write a command that dynamically calls the argument of another command

I would like to be able to dynamically call an argument. The following MWE is merely designed to illustrate what I want and nothing more: \documentclass{article} \def\aecommandA#1#2#3{%% ...
2
votes
1answer
306 views

Dynamically format labels/columns of a LaTeX table generated in R/knitr/xtable

I have some tables coming from the statistical package R that I want to export in LaTeX markup. I would like to make every column large as the longest word of its label (assuming for simplicity the ...
1
vote
1answer
139 views

Using variables to draw a tikz diagram

I am defind my own command to plat a diagram with tikz. Instead of constant values I rather want to pass numbers to my command which determine the height of the bars in my diagram. Problem: I am ...
6
votes
4answers
191 views

Standalone package, preserve preamble

Is it in a way possible to preserve parts of a preamble of a standalone document? For example when I have a savebox or a macro inside it and don't want to repeat it in the preamble of my main ...
1
vote
2answers
82 views

Place a document at the end but evaluate it at the beginning [closed]

I would like to collect certain \newcommands in an appendix, so that each one can have a section explaining itself. However, if I put this appendix at the end of the file, then I can't call the ...
9
votes
1answer
92 views

Documenting new commands

Texstudio displays a popup code-completion window for new commands that can give cues about what parameter does what and provides an explanation of the methods: I'd like to do the same with my own ...
9
votes
3answers
139 views

Why is the \endcsname not found in the following code

This is a precursor to my real question. But for whatever reason, when I tried reducing my code for something to post here, I got more errors. In particular, the following code gives me an error ...
5
votes
1answer
74 views

\savebox in page header with redefinable commands

I'm making a document class with some redefinable commands for page headers. However, I'm running into the following issue: \documentclass{article} \usepackage{fancyhdr} % In custom document class ...
5
votes
2answers
185 views

Bouncing ball over time

I have this clumsy code to plot the height of a bouncing ball over time. Is there a possibility for optimization? Perhaps writing the functions directly with the tikz math library? Also at the moment ...
6
votes
3answers
372 views

Adding vertical space (\vspace) around custom environment

I have document with custom environment myenv which left margin is 4em. \documentclass{book} \usepackage{lipsum} \newenvironment{myenv}{ \setlength{\leftskip}{4em} } \begin{document} \lipsum[1-2] ...
54
votes
4answers
3k views

Defining custom commands is bad style?

I recently received this in a e-mail from my professor Good LaTeX style would preclude creating any of your own commands, counters, etc. (Most journals would reject submissions with user-defined ...
4
votes
1answer
81 views

Using counters in macros to manage Beamer overlays

I have a very complex Tikz figure that is uncovered piece by piece during my presentation. While tweaking the presentation I decided to change the order of things being uncovered and due to the large ...
5
votes
1answer
175 views

Creating a simple list of symbols

Inspired by this great answer I tried to manually create a glossary-style environment for a simple list of symbols. Basically I wanted to create a command newsymbol that can be executed from anywhere ...
1
vote
1answer
116 views

How to create a macro for a customized frame in Beamer?

I'm looking for a way to create a macro like \chapterFrame{Title of the chapter}which adds a new slide customized as I want. As an (ugly) example, here is what it could look like. I tried the ...
3
votes
1answer
84 views

\newcommand with variable name

I am typesetting a long mathematical text (lecture notes), in which I use the alphabets \mathbb A \mathcal A \mathfrak A very often, so I decided to name them \A \sA \fA (For bb A, script A, ...
2
votes
2answers
122 views

Why can't I renew the \label command in math mode?

When I'm writing a paper and want to refer to a section, figure or equation in a different part of the document, I end up spending a lot of time scrolling through my source code so that I can see what ...
3
votes
0answers
41 views

Preserving the value of a macro outside the local scope [duplicate]

I'm writing a (supposedly) simple financial tracking program using tikz and the fp package. Within a tabular environment I compute a value using \pgfmathparse{adding some numbers}\pgfmathresult. ...
9
votes
0answers
83 views

create list of thumbnails for each section

I want to create a cooking book. There I want to define for each receipe a thumbnail image. At the beginning of each chapter I want to show instead of a TOC a gallery of thumbnails of each subsection ...
3
votes
0answers
32 views

Managing collections of shortcut-macros in collaboration projects

I write a lot of very similar documents, and thus make heavy use of shorthands such as % Partial derivative \newcommand{\pder}[2]{ \frac{\partial #1}{\partial #2} } As of now, I have a single file ...
7
votes
1answer
81 views

Reversing the effect of a \newline with the next command?

I'm using the harvard package and the agsm bibliography style. I'm aware that there are alternatives, e.g., natbib plus har2nat, and I will be looking into those in the not-too-distant future, but at ...
8
votes
1answer
104 views

footnote boolean: how to check whether currently in a footnote

Is there a way to check whether I'm currently in a footnote? (This question has already been asked on tex.stackexchange.com, but the accepted answer only provides a solution to the user's specific ...
11
votes
2answers
109 views

Determine whether the first non-space character of #1 is a letter?

Let's say I have a class file with \title command, and I want to check that the title starts with a letter, and not with math or a number or a symbol. How can I do that? This is my MnWE, the syntax ...
4
votes
1answer
156 views

Is it possible to define abbreviations for coding?

I am using the tikz-timing package to create a timeline since chronosys and chronology wouldn't cooperate and were too limited and archaic-looking to suit my purposes, and moderntimeline unfortunately ...
5
votes
2answers
193 views

define new command: \renewcommand{\longto}{\longrightarrow}

I define this new command: \documentclass[8pt,a4paper]{article} \newcounter{conto} \setcounter{conto}{\time} \usepackage{lmodern} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} ...
4
votes
1answer
55 views

Nested call for brackets

I need to create a custom command that behaves differently when it is called. For example consider \documentclass{article} \newcommand{\bkt}[1]{\left( {#1} \right)} \begin{document} ...
3
votes
1answer
56 views

Use of \Tree with a macro

I am using the qtree to produce some trees, for example with this syntax \Tree [.foo bar ]. Now, I have automated some part of the tree and get troubles. When I place [.foo bar ] inside of a macro, ...
4
votes
1answer
84 views

`split` not working with self-defined command

I have defined a handy little macro to typeset matrix elements in braket-notation and now want to align the next line to a part of this matrix element, because the equations are really long and ...
4
votes
0answers
79 views

Format \ref as a roman numeral? Strange bug [closed]

How do I get a \ref to format as a Roman numeral? At the moment I have the code: \newcommand{\appendixref}[1]{Appendix~\romannumeral 0\ref{#1}\relax} This works great... except for when it ...
0
votes
0answers
71 views

I need some help debugging this LaTeX macro - TeX “skips past” a bunch of code?

I'm trying to test and debug a collection of LaTeX macros that I've been working on, and I have run into a problem that has me totally stumped. Essentially, the problem is that at a certain point in a ...