4
votes
2answers
126 views

About \def\b*{\begin{align*}}

I want to make the code shorter. I defined the following pair of macros: \def\b*{\begin{align*}} \def\e*{\end{align*}} My point is that I saw this is a document, with \def\b*{\begin{eqnarray*}} ...
5
votes
1answer
267 views

Putting normal letters in between Greek ones

So I am trying to write out Gauss' law for gravitation and I am having a hard time figuring out how to write it out without an error. I am currently trying to write in an equation block ...
2
votes
1answer
58 views

Error: Command \ invalid in math mode

I am getting the following error: Command \ invalid in math mode. Why? Compilation ends but no PDF is created because of those errors. This seems to be the problematic piece of code but I don't ...
3
votes
1answer
33 views

\ifmmode check in section caption

To assure the correct usage of newcommands which only shall be used in mathmode, I have introduced a mathcommand, which checks mathmode by \ifmmode. Now I want to use such a mathcommand in a section ...
2
votes
2answers
114 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
2answers
49 views

Decrement macro, subtract 1 in side equation

While doing general math inside a math macro is not very feasible. I feel like a mecro that does, only for single digits should be possible, with default for other inputs \dec{1} to 0 \dec{2} to 1 ...
7
votes
2answers
79 views

Check if in an align* environment

I want to use different styles of matrices if TeX is in an align* environment or in a normal math environment. I already found a solution for checking if it is in math mode (\ifmmode) but not ...
4
votes
2answers
107 views

\renewcommand for \forall to add a parameter

Hi I'm trying to redefine the \forall command so that it accepts an argument instead of using the regular juxtaposition. What it looks like at the moment is ...
7
votes
1answer
101 views

New math command with alternative definition for inline mode

I'm interested in writing a command which would result in output that varies when called within $...$ tags and when called within, say, displaymath environment. For instance, assume that I want to ...
6
votes
1answer
140 views

Defining a macro with optional parameter

I like to define a macro with an optional parameter. As an example, consider a macro for the differential: \documentclass[11pt]{article} \usepackage{amsmath} \usepackage{bm} ...
9
votes
3answers
288 views

How to force LaTeX only commands?

Recently, I learned that for a long time I have been doing all of my mathematics in LaTeX incorrectly! I was using the $ TeX commands instead of the \( and \) LaTeX commands! I immediately went back ...
4
votes
2answers
139 views

Making aliases for variables

I'm trying to figure out how best to define an alias. I have some moderately complicated variable names, such as $p^{i,j}_{t}$, and having to type them over and over again is a pain. More importantly, ...
6
votes
1answer
74 views

@namedef and math mode

I am trying to do something simple: I want to be able to store and retrieve texts and equations via labels. In particular, I want something like \labelput{<label>}{<text>} % sets the ...
3
votes
2answers
100 views

The √ symbol in the unicode-math package

I'm using the unicode-math package in comination with xelatex. Thanks to this package I can write unicode symbols in the tex code. However some unicode symbols, don't compile the way I would expect ...
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 ...
5
votes
1answer
109 views

How can I define a macro with literal square brackets in the body?

The following macro works correctly for enclosing an expression in parenthesis. \def\group#1{\left ( #1 \right )} I want to write the equivalent macro for enclosing an expression in square ...
11
votes
3answers
110 views

Mirror tilde accent

Does anybody know if there is a "mirror" tilde accent command in any package? That is, the "wiggling" of the tilde accent going in the other direction. Something like defining this \backtilde ...
8
votes
2answers
124 views

Text misplacement with certains combinations of \mathring and \overline

If I try to compile the following document \documentclass{article} \usepackage{mathtools} \DeclareMathOperator{\Op}{Op} \begin{document} \[ 1 + \mathring \Op(4) = 2 \] \[ \overline{ 1 + \mathring ...
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 ...
6
votes
2answers
420 views

Putting \hat over first character of subscripted variable

I'm using a set of commands to define abstractions of mathematical notations that often occur during my thesis such as: \newcommand{\DNoise}{n_d} which would equal some distortion noise. This allows ...
4
votes
3answers
115 views

Need a new command that modifies the uppercase letters in its argument

I was trying to write a new command for expected value operator, such that if its argument is a uppercase letter then it will replace it with a \mathrm one, e.g. from E(X) to E(\mathrm{X}); and will ...
1
vote
1answer
52 views

Spacing in commands for math mode

I would like to define commands with semantics similar to e.g. + in math mode. For instance, $(x+y)$ produces an equation with some spacing around +, whereas $(+)$ produces an equation with less ...
12
votes
3answers
201 views

Multiple letters without spacing in Math [duplicate]

Is there something I can add to the preamble of my document such that multiple letters without spacing in a Math environment (such as $NP$) do not have extra spacing between them and are not ...
7
votes
1answer
114 views

Macro finding a forgotten \command

I do not know if this question has more to do with the editor I use (which is LaTeXShop, on Mac) or some clever LaTeX package, but I am typesetting some notes for a course and I would like to ...
1
vote
1answer
55 views

redefined math command printed with error [closed]

why is my command \mercur shown with error, but the default \mercury command without? MWE: \documentclass[10pt,a4paper]{article} \usepackage[latin1]{inputenc} \usepackage{wasysym} ...
3
votes
1answer
91 views

Retain line breaking behaviour inside macro

I use a macro which just wraps its argument in a pair of delimiters (brackets). It interferes with the way LaTeX would normally wrap an inline math expression. The following illustrates: ...
9
votes
3answers
252 views

Defining a macro for “real” colored delimiters

I recently looked up J. van Hoorn's question on How to color delimiters in Math Mode, and so I decided to test my LaTeX knowledge by trying to define a new appropriate command: ...
3
votes
0answers
30 views

Unexpect differences between calling \ifmmode from within a command and outside a command [duplicate]

In answering another question regarding testing for math mode, I proposed the following command \newcommand{\testa}{% \ifmmode ^{12}\text{CO(1-0)}% \else $^{12}$CO(1-0)% \fi } But ...
8
votes
2answers
154 views

Macro with environmental dependent output

I'm trying to develop a macro that gives two different outputs depending on whether it is in math mode (i.e. $ $ or \begin{equation} ... \end{equation}) or anywhere else. The reason is that I use a ...
5
votes
1answer
210 views

Macro for set intersection

I want to create a macro for intersections that can switch between cap and bigcap depending on the situation. Here is what I came up with based on browsing other posts on the forum. Are there any ...
3
votes
0answers
548 views

Texmaker. Color in the editor. Math mode [closed]

I am starting to use Texmaker with the default configuration. When I use the math mode ($...$) all of it is coloured in green in the editor, making long formulas difficult to follow. I would like ...
7
votes
5answers
154 views

Preventing math mode from parsing macro input as math?

Basic Problem I'm trying to produce a command sequence \m that Is called from within math mode, with a single argument list "Replaces" all instances , and ; in list with & and \\ (resp.) ...
3
votes
1answer
81 views

Change \newcommand behaviour based on the environment

I'd like to define a command \Lm, such that if used in a maths environment it is replaced with \mathcal{L}, but when used outside of the maths environment it would be replaced with $\mathcal{L}$. This ...
1
vote
2answers
133 views

newcommand for $\frac{\mathrm{d}^4q}{\left(2\pi\right)^4}$

Can you give any hints on how to define a new command that writes $\frac{\mathrm{d}^4q}{\left(2\pi\right)^4}$ with the options that one can write $p$ instead of $q$ (say) and also if one could ...
7
votes
2answers
85 views

Setting an “attribute” for Theorem to be accessed later

I am writing a math paper with a large number of theorems. I'm looking to have a table summarizing my results, and I'd love it if the table could be generated automatically from my paper. I' looking ...
5
votes
2answers
173 views

Double subscript error with \newcommand?

Disclaimer: I know of Defining a newcommand with sub- or superscript and avoiding "double subscript" error but this only gives a work-around, but no explanation to my question. Here's a ...
4
votes
1answer
121 views

Create “bracket free” macros (like in mimeTeX)

In mimeTeX, an abundance of macros like \cd = \cdot, \fr = \frac and \sq = \sqrt are allowed. This kind of macros are easily created in own LaTeX documentens, using \newcommand. Other mimeTeX macros ...
5
votes
1answer
70 views

How to build a conditional based on a resize paramater

I would like to define my own macro that accepts an optional parameter such as \big, \Big, etc that apply that if it is specified, otherwise apply the auto resizing \left, \right pair. So, how do I ...
3
votes
2answers
1k views

Is there a long division macro? [duplicate]

I want to do regular long division in latex. See also: http://en.wikipedia.org/wiki/Long_division Is there a latex macro for this ? Edit: I actually want to use it in mathjax, is this possible ?
6
votes
1answer
554 views

Applying condition around \intertext and \shortintertext leaves excess vertical space

When I try to make either \intertext or \shortintertext conditional I get excess vertical spacing prior to the conditional text as per the MWE below. Note the excess vertical spacing prior to "Albert ...
2
votes
1answer
62 views

Automate replacement of `\not` when in `\bm` mode

Hendrik Vogt has provided a \longnot macro to alleviate the issues related to Interaction of \boldmath and \not. This seems to work fine, but I run into a snag when I try to automatically use ...
2
votes
2answers
244 views

How to define new command for commands like \frac{} or \int{}^{}?

We know that we could define a new command for boldfaced or calligraphic C, for example I can define \newcommand{\Cx}{\mathbb{C}}, which will produce the boldfaced C, i.e. $\mathbb{C}$ for me. But how ...
7
votes
2answers
127 views

Using a character as a macro within another macro in (La)TeX

Goal: What I would like to do is to allow _ and ^ to be used to generate sub and superscripts in text mode only within a specific macro. I know that I can make _ and ^ active throughout the document, ...
5
votes
3answers
134 views

Remove math from command parameter to get only the letters

I use a little command, which prints new defined terms in bold, adds a label and adds them to the index. \newcommand*{\defined}[1]{{\bf #1}\label{#1}\index{#1}} Now if I do \defined{$G$-invariant} ...
10
votes
1answer
341 views

Interaction of \boldmath and \not

It seems that using \boldmath (or \bm) along with the \not does not quite work so well. Here is an example using \not\subseteq and \not\le where the line representing negation does not stretch ...
7
votes
1answer
559 views

cool package derivative and eulervm \mathbold fails with 'Missing control sequence inserted.'

Compiling \documentclass{article} \usepackage{cool} \usepackage{eulervm} \begin{document} $\D{a}{T}$ $\pderiv{a}{T}$ $\mathbold{T}$ $\D{a}{\mathbold{T}}$ $\pderiv{a}{\mathbold{T}}$ ...
3
votes
1answer
206 views

How do I create the following macros?

I would like to define the following macros. \newcommand{\NC}{\ensuremath{\mathbf{NC}}} \newcommand{\NC}[1]{\ensuremath{\mathbf{NC^{#1}}}} But LaTeX complains that \NC is already defined. So, I ...
7
votes
2answers
2k views

Shortcuts and/or user-defined shortcuts for math symbols in LaTeX?

I am very new to being able to use LaTeX to type up mathematical papers, and I just got my "system" set up. Currently I have installed TexWorks, and MikTex, and I have put together a 'hello world' ...
2
votes
1answer
80 views

Custom Command cannot use equation mode?

I have defined a new command below, but when ever I pass an equation into, it will not work. \newcommand{\defn}[1]{ {\textbf{Definition}}\\ \parbox{5.2in}{\begin{flushright} ...
4
votes
3answers
246 views

How do I define a math mode formula with a caret ^ in LaTeX?

This question has two parts. First, is there a way to define a macro only for math mode? Second, how do I specifically get the following definition to work correctly? \def\fi{f^{-1}} One ...