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

19
votes
0answers
175 views

Is there a reliable way to get the number of arguments of a command?

While pondering over a test to distinguish two versions of a command I came up with the following example: \documentclass{article} \begin{document} \def\testA#1{\#2->blabla} \typeout{\meaning\...
11
votes
0answers
667 views

Copy to clipboard feature in PDF output

I want a clickable copy to clipboard feature in my PDF document. Ideally the macro also allows for graphical elements to be embedded inside them (say, a button that will automatically copy paste ...
6
votes
0answers
373 views

Automatic dropcaps for the first letter of a chapter

I'm in the process of writing a LaTeX style for thesis dissertations, and would like to automatically transform the first word of a chapter to dropcaps. This is trivial to do manually using the ...
5
votes
0answers
25 views

Problem between keys, paths with two macros and pgfkeys

Sorry the code below for my minimal example is a bit long. In this code I defined two macros : the first macro \SC draws semi-circle and the second macro \ARC draws arcs. The first macro uses the ...
4
votes
0answers
30 views

Include semicolon in preamble definition for tikz macro?

Say I define a macro \arr in the preamble for use in a tikzpicture. Is it best practice to: Exclude the semicolon from the definition and include it in the tikzpicture, \documentclass{article} \...
4
votes
0answers
99 views

Getting negative vspace to behave

My TeX code (including parameters in command definitions) that creates lyrics sheets and chord sheets of songs is generated dynamically by other code accessing database data and processing it line by ...
4
votes
0answers
56 views

$\widehat$ prints a reverse paranthesis whenever argument length >5

I am using Babel Greek and the following code for my doc: \documentclass[titlepage]{book} \usepackage[vcentering,dvips,hmarginratio=1:1]{geometry} \geometry{ papersize={210mm,280mm}, total={150mm,...
4
votes
0answers
60 views

Strings and memory usage

The TeX engine was originally written in Pascal before dynamic memory allocation was generally available. Modern implementations tend to be done in C. To qualify as TeX an implementation has to pass a ...
4
votes
0answers
47 views

standalone package and user-defined macros/lengths

This is my first post on this amazing website, so hi to everybody!! I'd like to know if there is a way to pass some parametrs (macros or lengths) to a standalone file. Here is my MWE: Consider the ...
3
votes
0answers
146 views

TeX/LaTeX macro to find out where am I in a tabular

Do you know a macro/command which can tell me where was it called in a tabular environment? Specially, i wish a macro which executes \commandA if I called it in the first cell of a row (or after a \\ ...
3
votes
0answers
29 views

Can I force a pre-process action on all commands or environments without having to redefine them all manually?

I am trying to preserve a history of the latex commands and environment initializations I use in a typeset html or pdf file. Is there a way where I can force a pre-process action on all commands ...
3
votes
0answers
79 views

mouse over (highlight) acronyms using acronym package. is that possible?

Is it possible to highlight acronyms (mouse over shows the acronym definition) by using the acronym package \ac ....? In this post, there is a macro that was working somehow but by using the acro ...
3
votes
0answers
97 views

Retrieving coordinates of every character in a formula

I'm writing a program that uses LaTeX to display formula's. The user must be allowed to click on different parts of the formula, and the program should know on which part the user clicked. Is there ...
3
votes
0answers
62 views

A mysterious blank line come from an \hskip?

I use a very complicated .sty file. The main purpose of this .sty is to enable a special inline box in which texts can be typeset in a very special way. There is no problem inside the box. The .sty ...
3
votes
0answers
433 views

Passing an array type argument for new command

I've looked around and can't seem to find anywhere, but I was wondering if there is somewhere you can do something like the following: \newcommand{\loopy}[1]{ \begin{tikzpicture} \foreach ...
3
votes
0answers
257 views

looking for selective latex command replacement methods

I have a perl script for generating wordpress (or physicsforums or wikipedia) style latex markup from standalone latex files, but it has grown into a bit of a monstrosity and has also recently met it'...
3
votes
0answers
194 views

Duplicate Line command in TeXShop for Mac

I'm a quite new user of LaTeX and one thing I miss in TeXShop on mac is a "Duplicate Line"-command, espacially when writing mathematical derivations. It's my impression that it is possible to create a ...
3
votes
0answers
378 views

Using the correct amount of space around unit symbols

This is from an old package I developed back in 2003. The idea was to cover international system units (SI) and other type of units, roughly following guidelines from that document. Units should ...
3
votes
0answers
126 views

A problem with using the \ganttbar macros inside another one

I'm trying to write a macros for converting day time to a format, which the pgfgrantt package can understand. Here it is: \newcommand{\htime}[2][0]{ \StrBefore{#2}{:}[\hours] \StrBehind{#2}{:}[\...
2
votes
0answers
42 views

\strip@pt\textwidth gives “undefined control sequence”

I'm sure that this is something silly, but I've been beating my head against the statement \strip@pt\textwidth giving "undefined control sequence". I'm trying to modify some drawings in tikz widths ...
2
votes
0answers
26 views

Collecting and analyzing data presented in tables

I have data presented in tabular environments and I want to process it, in LaTeX, in ways that require for multiple cells to be analyzed together. That's in addition to typesetting the cells ...
2
votes
0answers
70 views

Automatic lettrine in chapters

I'm trying to get lettrine dropcaps applied automatically on the first word of each chapter. I found some code here: http://dererumnatura.us/archives/2009/02/automatic-usage.html which I've tried ...
2
votes
0answers
64 views

Trouble with frame in newcommand

I'm making a slideshow with LaTeX beamer class like this : \documentclass[xcolor=dvipsnames]{beamer} \usepackage[french]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{...
2
votes
0answers
47 views

Macro with \afterassignment syntax?

Say for some reason I want to make a macro with input stream behaviour mimicking that of \afterassignment and \aftergroup. Namely, I want to absorb exactly one token from the input stream following ...
2
votes
0answers
70 views

A \newcommand type option that runs all subarguments and saves static text

I am trying to write code that uses sage in it, and have a bit of a problem with randomizing stuff around the code. The sagetex part isn't too important (I don't think), what is important is that if I ...
2
votes
0answers
163 views

How can I migrate commands and environments from LaTeX2e to LaTeX3? [XeTeX]

Sometimes forcing consistency makes things much easier to maintain. The motto "keep it simple" comes to mind. xparse offers the most bang for your buck when it comes to defining commands with various ...
2
votes
0answers
79 views

Unwanted vertical space at top of page before subsection heading

I have been using LaTeX for a while now, but I am very new to defining my own commands in the preamble. I am working on my thesis, and I'm using a custom .cls file which has been passed down by other ...
2
votes
0answers
49 views

Adding default \skew to math accents

Out of corporate design reasons I should use Helvetica for my documents. I could simply ignore this, as most people do ;-) But out of fun I just combined ideas taken from sfmath and beamer to make ...
2
votes
0answers
79 views

Autocomplete in TeXstudio for macro with optional argument

I have a macro, such as \newcommand*{\example}[2][]{#1.#2} defined. TeXstudio adds this to its autocomplete list, which is great, but when I actually autocomplete it shows up as \example{arg1}{...
2
votes
0answers
78 views

How to create command to make custom Indicator Function

So, I've found this package for common probability items in LaTeX and the very last entry is a "customizable" indicator function in which one simply inputs the variable (e.g. x) and it returns \mathbf{...
2
votes
0answers
55 views

Display shortcuts other than urls with href

Big picture, I am trying to develop an approach that will allow me to store the latex commands and labels (pre-expansion) that I use to typeset dynamic text (bib entries with cite, cross referencing ...
2
votes
0answers
58 views

Typeset code within a simple macro?

I want to use a macro to typeset programming code with the usual characteristics (particularly lines should be obeyed - this is the most important issue; highlighting and such stuff is - for now - not ...
2
votes
0answers
55 views

\ifbeamer@anotherslide and \ifbeamer@localanotherslide in beamerbasedecode.sty

At the beginning of the source file beamerbasedecode.sty of beamer class, two switches are defined: \newif\ifbeamer@anotherslide \newif\ifbeamer@localanotherslide By reading beamerbasedecode.sty ...
2
votes
0answers
190 views

soul for text highlighting, microtype for letterspacing, and xspace: incompatibility

I am trying to use soul for highlighting text and microtype for letter spacing (and other things). But I cannot get the two to work together nicely when I include xspace (I use this mainly for ...
2
votes
0answers
75 views

Correct way to make command defined in tikzpicture environment (in an example) available in all documents?

The wonderful answer to the question Easy curves in TikZ shares some code that is defined inside a tikzpicture environment. I share the relevant portion of the answer here: Here is a slightly ...
2
votes
0answers
101 views

Generating LaTeX reports from XML *without* external scripts

First of all, I apologize if this is pretty similiar in nature to my previous question: Reading and (custom) formatting a CSV (not \csvautotabular) I thought it would be better to separate the two ...
2
votes
0answers
117 views

Different colours for each argument and value in listings

This recent question (Print blue brackets in one language and black in another) made me come up with (up to) two more questions regarding the listings package: Is there an option similar to opstyle ...
2
votes
0answers
96 views

\ref to \label in other document?

I have a repository with one document, but I think of splitting it into two documents, whereas I want to cross-reference from one to eachother. Is there a way, to "rewrite" \ref to automatically ...
1
vote
0answers
24 views

Texmaker user command puts filename in quotes

Following this advice: Integration of arara in Texmaker, I defined user command in Texmaker. Yet after running a command, I get a message: Error : could not start the command : arara "mgr".tex ...
1
vote
0answers
70 views

Where to put plain TeX macros so MiKTeX finds them

I have MiKTeX 2.9 working except it can't find the files (.tex macros) when the source file (always plain TeX) refers to them as in \input mac2 I do have a TDS-compliant directory called \...
1
vote
0answers
41 views

Package that fills pages to total number of pages devideable by 4, 8, 16

I'm doing a package right now, which is capable of filling in empty or custom pages to get a total number of pages which is devideable by a defined number. I just want to make sure, that a package ...
1
vote
0answers
52 views

Macro: Replace all occurrences of words which are identical to content of \label{…} into \nameref{…} (unless of course the \label itself)

This question is a follow-up of Macro: Replace all occurrences of a word, but would like to ask for a possibility to do the same with words (e.g. foo) that are identical to the contents of certain or ...
1
vote
0answers
68 views

Using /csname in

I want to use a smarter solution for a big CSV file with many LocalX columns \documentclass[a4paper,12pt,hidelinks]{article} \usepackage[utf8]{inputenc} %\usepackage[utf8x]{inputenc} \usepackage[...
1
vote
0answers
76 views

Terminate and Start and environment from within the environment

How can I terminate and resume an environment by another environment? This also seems to have broken the resume feature which was resolved in Define a List that is Always Resumed. The code \begin{...
1
vote
0answers
48 views

xparse verbatim argument removing multiple space

I am trying to define a command, using xparse that take as input some verbatim code and cite it using listing. However, the eventual multiple white spaces or tabulations at the beginning of a lines ...
1
vote
0answers
48 views

Escaped characters in labels

I am writing some API documentation, and since I don't like to repeat myself I would like to make some commands and call those for parts that get repeated a lot. However, I am having trouble with ...
1
vote
0answers
61 views

How can I costumize the ToC for 2 different types of chapters?

I already have ((re)new)defined a 2nd type of the \chapter macro for I have two different types of chapters. But they have one counter, which appears for every chapter in ToC. Here's a MWE: \...
1
vote
0answers
35 views

Protecting \@ifnextchar inside pgfplots

I'm having trouble figuring out what I need to do in order for my definition of \sin to be accepted by pgfplots. I've looked up stuff about using \protected but it's vague to me how I'm supposed to ...
1
vote
0answers
29 views

How to create command that associates pieces of content to keep them on same page?

I've pieced together a class for my preferred format of Cornell notes, and it allows for floating a summary to the bottom of a page. But, it requires manually choosing the page that will host the ...
1
vote
0answers
130 views

TexStudio won't respond to ctrl shift -

[Ubuntu 14.04 TeXstudio] I'm trying to bind a macro to the ctrl shift - key combination, and even though Tex Studio accepts (and correctly displays) my combination in the Options->Configure TeXstudio-...