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

Overwrite \def to check if the command exists?

LyX supports math-macros, but sadly when passed to the latex processor, they are defined by a \def rather than a newcommand. I have found overwriting commands (e.g. using \def\v{\mathbf{v}}) to ...
3
votes
1answer
40 views

linebreak and pagebreak wherever I want with justified margins

I am looking for two commands: \mylinebreak \mypagebreak The first is supposed to break a line at the very position where the command is set and make the previous line justified (and not ...
8
votes
3answers
133 views
+50

How to parse multiple arguments in TeX macros

I have dates formatted {yyyy-mm-dd}. I would like display the time elapsed between the dates in the form Y years, M months. Given the format of the dates, it seems easier to use arithmetic than to ...
3
votes
1answer
71 views

Using \newcommand, \input and \includegraphics

I am writing a paper that includes simulation results from performing a number of trials of an experiment. Each of the output figures (.pdfs) I produce includes the number of trials in the filename ...
3
votes
3answers
140 views

Check macro argument has correct format

I have a macro which will read in arguments in date format e.g. {2012-11-08} \usepackage{datetime} \def\customdate#1#2#3#4-#5-#6\relax{% \shortmonthname[#5] '#3#4% } However, in some instances I ...
3
votes
2answers
46 views

Inserting macros mixed with static options

I've been trying on and off for a few days to wrap my head around the following. I want to insert options defined in a macro alongside options statically defined into the option list of another macro. ...
5
votes
1answer
37 views

macro value can not be updated in tabular with multirow columns

I am writing a command \newrow to generate one row in a longtable. The problem is that the tabular environment here can not see the value of \subColWid (output is 0pt). This occurs only when multirow ...
1
vote
0answers
28 views

macro for glossaries counter

I want custom my glossaries, and specially I want to have something like My glossary entry, its signification (see p. 1), if this entry mentioned only once or My glossary entry, its signification ...
1
vote
1answer
86 views

Opinions: Circuit_macros or circuitikz ? what is better? [closed]

I'd gladly read your opinions on Circuit_macros pros and cons, as well as yours on circuitikz. Gives the macro more variables to play with? Is the circuitikz language easier? Macro use seems far more ...
0
votes
0answers
49 views

Ignoring parts of text inside macro

Consider the following code: \documentclass{book} \usepackage{pgffor} \begin{document} \newcommand\containers{ \cont{aaa{\bf don't xstring me}aaa} \cont{bbb\large bbb} ...
2
votes
1answer
35 views

renewcommand the chapter in chinese problem

I move code from Miktex into Texlive. But I get errors: Run in Xelatex ! Undefined control sequence. \chaptername ->第\CJKnumber {\thechapter }章 l.33 \chapter{绪论} ...
2
votes
1answer
47 views

marginpar in a macro steal the bullet of itemized list

I have an odd (to me) problem involving an itemize environment and \marginpar{}. The problem is illustrated in the following document: \documentclass{article} ...
0
votes
1answer
30 views

Problem with \newcommand{\nal}{\end{align*}} [duplicate]

Why do these newcommands result in error when used? \newcommand{\bal}{\begin{align*}} \newcommand{\nal}{\end{align*}}
2
votes
2answers
60 views

What is the difference between a package and a template in LaTeX?

I was looking at the post How to disable automatic indentation on new paragraphs? and the given comments. It was suggested that I go to Ask Question. Which is what I am doing now. Somebody was ...
4
votes
2answers
46 views

Trouble using convertchar and thestring inside a LaTeX command or table

I'm trying to generate page references inside a command that defines a row of a table, with the name of the label being referenced generated as a result of some string maniupulation using ...
6
votes
4answers
87 views

Using MakeLowercase and StrSubstitute together

I'm using LaTeX and have a string that I want to remove underscores from, and convert to lower case (in either order). The individual steps work: \MakeLowercase{AB\_CD} \StrSubstitute{AB\_CD}{\_}{} ...
1
vote
0answers
19 views

Defining New Command with regular text inside math mode (Notation) [duplicate]

I would like to denote the volume of a lattice as vol $L$ and the determinant similarly as det $L$, so that the words "vol" and "det" are in the normal/regular text format but the L is in mathmode. ...
3
votes
3answers
102 views

How to use a macro to store the default pgfplot properties

I have some default settings for my pgfplots plots, such as xlabel, ylabel, width and so on. Since I have a large number of such plots and don't want to repeat all the properties, I want to store them ...
4
votes
2answers
118 views

Problem with defined macro and blank lines

I am using the following command to color some text: {\color{NavyBlue} Text Here! } Because I used it frequently I created this macro: \def\cl#1{{\color{NavyBlue}{#1}}} When I am using the ...
0
votes
0answers
18 views

Automatically enclose \glt line from gb4e in \enquote{}

How can I automatically enclose the \glt (\trans) line in gb4e's interlinear glosses in context-aware quotation marks with \enquote{} from csquotes? \documentclass{article} ...
4
votes
1answer
55 views

Probsoln customization of solution environment (set as marginpar)

I'm using probsoln, and I want to put the solution as a marginpar and with footnotesize. Please look at the MWE below. Writelatex won't compile, spitting out LaTeX Error: \begin{solutionnew} on ...
0
votes
1answer
48 views

Variable number of arguments for \newcommand

I use the following command to write my matrix variables \newcommand{\mymat}[3]{\ensuremath{\mathbf{#1}^{#2}_{#3}}} Thus #1 is the matrix variable, #2 is the superscript and #3 is the subscript. ...
2
votes
1answer
51 views

PGFPLOTS: How To Put \addplot boxplot prepared Inside Macro Definition

I have a need to wrap the `\addplot [boxplot prepared]' inside a macro to greatly save typing. It seems simple enough, but the devil is in the details with macro expansion issues. Is this doable given ...
6
votes
1answer
30 views

Value of \def specified via command line not being properly recognized

I am having difficulty understanding why defining a macro on the command line is being treated differently than if it is specified in the file. The MWE below allows \FormattingMode to be set to Print ...
1
vote
1answer
66 views

pgfplots: Optional graph range arguments in a macro

I defined a macro that inserts a plot that I can re-use the same graph style in multiple places. Mine actually loads data from a file, but a similar MWE looks like: \newcommand{\drawGraph}[1]{ ...
4
votes
1answer
63 views

Problem grouping environments

Below are two examples. The first one works fine, no errors no warnings, but on trying to build a doc from the latter, I get a heap of errors. Working: \documentclass[]{article} \usepackage{environ} ...
2
votes
0answers
37 views

How to divide underline with ULEM package?

In some Chinese books, proper nouns were underlined uncontinuously. How to divide underline with ULEM package, as in the first pic? I changed the ulem package, and want to seperate some words, ...
6
votes
2answers
140 views

Trying to convert Hrs:Mins to Mins

I am having a bit of trouble trying to convert a time format from Hours:Minutes for instance 12:05 into 12*60+5 = 725, ie I would like to use 725 as a number of minutes. I am already using the number ...
0
votes
0answers
30 views

Having a problem generating a command that make chapter and label in one line

I'm writing my thesis, modifying the ezthesis template. I did a new command that mix chapter and label in one line. \newcommand{\chaptercolored}[2]{\textcolor{colorchap}{\chapter{\textbf{#2}}}% ...
3
votes
1answer
35 views

Pass blank as argument to a command

How can I pass a blank to this command \newcommand{\iam}[1][happy]{I am #1.} so that I get this result I am . Note: My actual command operates in the math mode, so the space between "am" and "." ...
2
votes
1answer
51 views

newcommand with \href [duplicate]

I'm having trouble using newcommand with the \href I would like a newcommand like this: \newcommand\link[2]{\href{#1}{\underline{#2}}} This command works fine quite all, for exemple: ...
3
votes
2answers
238 views

How to redefine “\ ” (that is “<backslash> <space>”)?

In (La)TeX, is there a way to redefine the command \  (that is "<backslash> <space>")? I have lots of texts where \  is used as non-breakable space after "." characters like in ...
3
votes
1answer
96 views

How best to differentiate questions and answers in a document without compromising on typesetting and readability?

Preliminary note: I don't think this question is completely or even to a large extent subjective, as it seeks how to achieve objective utilitarian goals. Please read: I am solving my QFT assignments ...
4
votes
2answers
55 views

Put text into small parts of a picture

I have used the \multiput command to create a for example 4 by 4 table: \documentclass[a4paper,12pt]{report}‎ ‎\usepackage{graphicx} % inserting images‎‎ ‎\begin{document}‎‎‎‎ ‎‎ ...
2
votes
2answers
54 views

What macros do I have to invoke to get the day of month, month, and year?

What macros do I have to invoke to get the day of month, month, and year of the current date? I am a beginner in LaTeX.
1
vote
1answer
68 views

LyX command(s) to insert WYSIWYG horizontal line, for keyboard shortcut

Using the menu entry Insert > Formatting > Horizontal Line I can insert a WYSIWYG horizontal line into a LyX document. I want to figure out the internal command(s) used to do this so I can set up a ...
5
votes
2answers
45 views

New command adding extra space

I'm having a problem with a command with empty output adding an extra space. I have a large document that needed a number of corrections. To highlight the text added and removed for easier review, I ...
3
votes
1answer
30 views

Help for a complicated macro: breaking pages at custom places and itemize environment

In this answer, there is a macro that allows one to have a precise control of the page lengths of a document. This macro is too complicated for me and I have found a problem with it. It behaves ...
0
votes
0answers
24 views

How to use function \newcommand to turn off math mode? [duplicate]

I have a problem. I defined new commands: \newcommand\be{\begin{equation}} \newcommand\ee{\end{equation}}, which works perfectly for math mode. Then I tried with more advanced formulas: ...
5
votes
1answer
50 views

How can I write a command that defines another macro which may optionally be prefixed by \global?

In various contexts I define a macro such as \makeatletter \newcommand\aedosomething{\ae@do@something} \def\ae@do@something#1#2#3{%% %% do something with arguments #2 and #3 \def#1{<result ...
4
votes
3answers
131 views

Expansion Issues When Passing TikZ Styles to Macro Created by Macro

I'm struggling (again) with expansions. This time I have a generic function \misdirection that creates a TikZ environment subject to a few options. Then, I create a macro \freezeStyle that creates a ...
3
votes
3answers
105 views

Processing Plain Text

I'm currently trying to typeset a plain text file that has a certain structure. There's one thing that I can't get working, and that is the following. My plain text is structures as follows: "lorem ...
1
vote
1answer
34 views

I cannot run texnic centre on my miktex

When I try to run latex.exe on my document, the following shows up: C:\Program Files (x86)\MiKTeX 2.90\miktex\bin\latex.exe Cannot execute the command. Error:The system cannot find the file ...
0
votes
1answer
58 views

Bold or arrow vectors with new command

Im quite new to latex, I would like to make either bold or arrow vectors. I found many solutions to this but i cant see where i am doing it wrong, my code is \documentclass[a4paper,11pt]{report} ...
7
votes
2answers
99 views

Reuse command portion in LaTeX

I defined several new code environments (using listings' lstnewenvironment); they all share the same attributes except one (the language used). For example: \documentclass[a4paper,12pt]{book} ...
3
votes
1answer
21 views

Using \snoc as macro name inside mathpar

I'm able to define a macro called \snoc but unable to use it inside a mathpar environment: \documentclass{article} \usepackage{mathpartir} \newcommand{\snoc}{hi} \begin{document} \begin{mathpar} ...
0
votes
0answers
15 views

how to use \savesymbol for the bibliography?

My bibliography contains, among others, several words in polutonikogreek. I haven't found a better way than to use the polutoniko-macros from teubner. As some other package redefines the macro \aa ...
3
votes
1answer
47 views

Opening and closing brackets in combination with the ifthen package

Related to this question, however, I was not able to solve my problem. Let me give some background. I want to switch between the article style and a specific journal style. The journal style has ...
5
votes
1answer
132 views

I want to include a closing bracket } in a \newcommand definition

I want to use the closing bracket in a \newcommand definition. I can give more explanation as to why, but this seems unnecessary at the moment. Obviously the MWE does not work, but how to make this ...
2
votes
2answers
51 views

Passing the value of a register as a macro argument

I'm looking for a solution to the following problem: \def\m#1{{ \dimen0=200pt \#1=\the#1 % Outputs 200pt rather than 100pt }} \dimen0=100pt \m{\dimen0} EDIT: The code sample above ...