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

1
vote
1answer
42 views

Why doesn't TeXstudio produce {} for my custom commands?

I'm having the following problem in TeXstudio 2.7.0. I have a template where I've declared some custom commands, such as \newcommand{\myAnswer}[1]{ \begin{itemize}[leftmargin=*] ...
14
votes
0answers
424 views

A flexible derivative macro with LaTeX3

In an earlier post I asked a question about writing a flexible derivative macro, and someone suggested that a LaTeX3 version might be easier to understand, so I decided to try my hand at writing one. ...
8
votes
0answers
61 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 ...
5
votes
0answers
413 views

Trying to make an automatic histogram (in pgfplots?)

How can I convert the automatic table generated by the macro, to an automatic histogram? Is the best way do it using pgfplots? \documentclass{article} \RequirePackage{ifthen} ...
4
votes
0answers
39 views

Variable Input/Output node using a new command

How can I create a variable input/output node using a new command as in the following picture Say for example, I know that the node will have n inputs and m outputs, which I enter the name as an ...
4
votes
0answers
84 views

Conditionals—do something, if a given command is being used in the document

Is it possible to have a conditional that allow us to do something if a given command is being used in the document? For example for the \part command would be: ...
4
votes
0answers
55 views

xparse with underscore and optional argument

I need a macro which handles its input as follows: \foo A > #2 = A \foo{A} > #2 = A \foo(B) > #3 = A (round brackets) \foo_m A > #1 = m, #2 = A \foo_m{A} > #1 = m, #2 = A \foo_m(B) > #1 = m, #3 = B ...
3
votes
0answers
56 views

pdflatex: How to automatically quit on compile error?

See also this question on Reddit. I want to automate running pdflatex over and over with make and guard. However, when pdflatex encounters a syntax error, it hangs, preventing guard from being able ...
3
votes
0answers
30 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 ...
3
votes
0answers
72 views

Replacing text with another one

I need a command to replace the text from left to right given below. for example the command should change ü into \"{u}. I found some command about this but i could't apply. {ü}{\"{u}} {ğ}{\u{g}} ...
3
votes
0answers
72 views

Custom commands for `xymatrix` paths

I would like to define a custom command to replace \ar@{->}`r[d]`[l]`[llld]_-{\delta}`[d][lld] in this bit of code: \[\xymatrix{ \cdots\ar@{->}[r] & H_n(X)\ar@{->}[r] & ...
3
votes
0answers
89 views

How can I tell which of several solutions to a LaTeX problem is the fastest/most efficient?

Consider this TeX/LaTeX StackExchange question I posted yesterday. I asked for a way to create a particular macro with a somewhat idiosyncratic calling pattern, which is not trivial to code. After ...
3
votes
0answers
97 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] ...
2
votes
0answers
49 views

tikz command fails after .cls file change

The following tex content is a part a tex file which is added to main file with command input. With a new .cls and some other unrelated changes, tex isn't compiling with error message of ! Package ...
2
votes
0answers
74 views

Problem with overwriting diagram files using feynmf

I've just installed feynmf package and tried working with a standard example. I'm working with MikTeX 2.9 on Windows. The compilation worked fine and I got the diagram in the PDF, but when changing ...
2
votes
0answers
162 views

ProvidesPackage and usepackage

I have seen papers containing a command \ProvidesPackage. Is it different than \usepackage? What is the difference between \ProvidesPackage and \usepackage?
2
votes
0answers
99 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 ...
2
votes
0answers
91 views

problem - multiple index in latex

I find here an example and use it for my multiple index. This code in Latex works, but I want to use the newcommand \smindexxspecial[\ITerm]{beccari} instead \index[\ITerm]{beccari} or ...
2
votes
0answers
64 views

Create all queries in separate file like \listoffigure

I would like to print all the queries collect from the article and need to print in article opener page. How do achieve this? My MWE: \documentclass{threecolumn} \begin{document} \jnltype{37} ...
2
votes
0answers
225 views

LaTeX: Beamer with \newcommand

I have tons of slides starting with \bslide I tried to rephrase my source for class Beamer by defining \newcommand{\bslide}{\begin{frame}{xxx}} Unfortunately LaTeX says ...
2
votes
0answers
115 views

Put ampersand (&) inside conditional

I'm trying to make a command that formats the alternatives of a test. Can I put an ampersand after each alternative? (I call my tabular command out of this command, and I want to put each alternative ...
1
vote
0answers
17 views

Can I use Writer2LaTeX and the `mla-paper` style together?

I use LibreOffice 4.1.3.x, and have had success using a patched version of Writer2LaTex with documents created in LibreOffice Writer. I want to create a (sub?)filter for Writer2LaTeX that allows me ...
1
vote
0answers
40 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
25 views

Bibtex-like macros organising software

From what I gather (I don't use them, and have never actually managed to get it to work - though this is not my issue), bibtex/biber uses a database of references, alongside an ancillary file created ...
1
vote
0answers
41 views

How to define pathname variables?

How do I define a variable (pathname) that can be recognized by various commands, such as \input{} and \includegraphics{} ? I tried the following \newcommand{\patha}[]{./folderA} \def \pathb ...
1
vote
0answers
56 views

Is it possible to change the \cite command in the following way?

I know this does not follow very good citation guidelines, but I want to change the cite command so that in addition to whatever the current bib file dictates, it will also print in the name of the ...
1
vote
0answers
62 views

Vertical spaces around display math

(First of all, I know that \[ \] should be used instead of $$ $$ and I do it.) I'd like to know about the vertical spacing around math display blocks. According to texdef -t latex \[ we have \[: ...
1
vote
0answers
48 views

Would I use \catcode, tokens, or look outside of tex for a markdown-like parser solution?

My use case: a LaTeX template for courseware designed in a beamer presentation style. The template I'm designing is company-specific and the specificity of the company's presentation guidelines limits ...
1
vote
0answers
63 views

frame in NewDocumentEnvironment

With beamer frames, this does not work. \newenvironment{itemframe}[1]{ \begin{frame}{#1} \begin{itemize} }{ \end{itemize} \end{frame} } Adding fragile, environment=itemframe as an ...
1
vote
0answers
42 views

Shortcut for Variable-Taking Command

I'm working with vectors, which I'm denoting with $\overrightarrow{a}$, where a is just the name of the vector, and thus is a variable that can take any value. I would like to redefine this as ...
1
vote
0answers
73 views

How to modify some command (like \begin{flalign}) so I can use it as my own

my first post as every beginner starts with question and later on I will give answers :). OK, I am doing my undergraduate work (to become graduate) in Electrical Engineering and I choose LaTeX as ...
1
vote
0answers
141 views

Insert code snippet via keyboard shortcut in TeXworks

I know there already are questions (1, 2) on creating keyboard shortcuts in TeXworks. The discussion (also in the Google thread referred to), however, seems a little outdated. By now, there is the ...
0
votes
0answers
30 views

A command for including a folder of macros

Is there any command to include a folder of macros(such as sty,def,... files) in preamble like one for grapphics (\graphicspath{{figures/}}‎‎).
0
votes
0answers
51 views

Macros for the subscript and spacing

I would like to define the command A\!\!_B\!C in a math mode as a macros, and I am using the following: \newcommand{\cmp}[3]{#1\!\!_#2\!#3} Unfortunately I get an error that there are {} missing. ...
0
votes
0answers
64 views

Mass replace custom macros in a LaTeX document?

I'm typesetting a document and to make it more editable I'd like to find a nice way to write the document making custom commands left and right for my ease, then go and replace them with their ...
0
votes
0answers
65 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 ...
0
votes
0answers
44 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 ...
0
votes
0answers
37 views

Choosing what to \ref from a \newcommand

I have this definition in my class (thanks to this answer): \newcommand\clause{% \immediate\write\@auxout{\string\expandafter\gdef\noexpand\csname ...
0
votes
0answers
65 views

Splitindex: How do I make splitindex either ignore \ or make verbatim work with splitindex?

I´m trying to set up an index for a custom command called \propDesc. This command highlights properties and their description: \newcommand{\propDesc}[2]{ \fcolorbox{white}{propbg}{ ...
0
votes
0answers
59 views

Calling filename@parse inside a command definition fails

I am trying to redefine \includegraphics to both auto-label the included figure and to restrict the maximum width. The auto-labeling is done by transforming the base filename to camelcase using the ...
0
votes
0answers
35 views

Improve command definition to avoid possible break

The following defines my MWE: \documentclass{article} \usepackage{amsmath} \usepackage{totcount} \newcounter{totalpoints} \regtotcounter{totalpoints} \newcommand{\shcpoint}[1]{% ...
0
votes
0answers
68 views

Defining #1^#2 as \overset{#2}{#1} for some characters

When I write math in xelatex, I like notation such as: $x \overset{ℝ}{+} y$ $x \overset{f}{↦} y $ $x \overset{(1)}{=} y$ However, as I type things like this so often, I would like to type it ...
0
votes
0answers
33 views

Employing options of the figure or table environment via \newcommand

I am writing a large document in which I would like to employ the options of figure environments via \newcommand{\figposa}{H} \newcommand{\figposb}{T} \newcommand{\figposc}{B} ...
0
votes
0answers
116 views

Detect a newline after dollar $ sign

I would like to be able to use \ifnextchar to check if the next character is a new line character. The reason is that I would like to redefine the $ sign to behave differently if it is followed by a ...
0
votes
0answers
26 views

AucTex region preview produces a document with ~10× more pages than the region preview should be. Cached preamble issue?

I define the following \locallabels{} command to localize labels and references to a certain part of my document \makeatletter \AtBeginDocument{% \let\origlabel@in@display\label@in@display ...
0
votes
0answers
82 views

Abbreviated syntax for CALS package

The cals package allows to create the tables with design capabilities which are available in Microsoft Word. This package is not based on tabular and has more bulky syntax than tabular. I'm try to ...
0
votes
0answers
107 views

TeX, LaTeX capabilities in counting occurrences in text of chars defined in a given list

I am asking this question in part because I am not completely aware of TeX, LaTeX capabilities. Imagine that I want to count the number occurrences of charecters defined in a certain list. The usage ...
0
votes
0answers
115 views

How to make a package using sagetex and sage-commands

I am trying to make my own package building on sagetex. It starts with \RequirePackage{sagetex} and I want it to execute some 'sagesilent' code as for instance \newcommand{\loadsagefunction}{ ...