0
votes
0answers
29 views

Math display help [duplicate]

I need help for what command I should do. I have a sentence, and in the middle of the sentence I use a math stuff then, more words. The part with math is smaller and smushed up. I do not want to begin ...
3
votes
1answer
73 views

Why is it recommended to put \relax before \ifmmode?

I've several times seen the recommendation to put a \relax before \ifmmode in a macro. I've tried searching for an explanation of this several times on this site, but hadn't been able to find one. An ...
1
vote
1answer
58 views

Redefining \^ and \~ in math mode?

\^ and \~ apply accents in text mode, but each gives an error when used in math mode. So I consider redefining them for my own use, perhaps like this: \let\old@hat\^ ...
5
votes
1answer
43 views

Avoid brackets with a command having an optional argument as subscript

I have the following code: \documentclass{article} \newcommand{\quot}[3][c]{\frac{#2}{#3#1}} \begin{document} \LARGE $A_\frac{a}{bc}$ $A_{\quot{a}{b}}$ $A_{\quot[d]{a}{b}}$ \end{document} If I ...
3
votes
2answers
87 views

returning maths values in a new command

So I'm trying to construct a command which calls another command to make typing easier, but for some reason I'm not able to get the commands to return things properly. Here is what I have ...
6
votes
2answers
78 views

Using \mathpalette with macros that take more arguments

As I understand it, \mathpalette takes two arguments; the first must be a macro A that itself takes two arguments. A will be passed as #1 commands to reproduce the math enviroment at the location ...
1
vote
0answers
25 views

Macro for textinput without any formatting [duplicate]

Is there a LaTeX macro that just compiles whatever I type into it? Something like \text or \textnormal. I want to display a LaTeX code inline without any formatting, but don't want to escape ...
4
votes
1answer
48 views

Arbitrary positioning in math mode without size restriction

In the MWE below, are all general methods, of achieving arbitrarily shifting of symbols up or down or left or right in math mode, represented? If yes, that is the answer. If no, what good methods are ...
4
votes
2answers
51 views

new command using math mode sub index bug

I have defined the following command \newcommand{\gsubselector}[2]{$s_{#1,#2}$} and I'm calling it from a document in the following way: ... \gsubselector{a,i} : \gsubselector{b,j} there is ... ...
7
votes
1answer
280 views

What generically CANNOT be compiled inside an equation environment?

Certain macros or whole environments which are themselves not equations, like whole tikz diagrams can be placed in the equation environment and compile. For example Diagram displayed as an equation ...
7
votes
3answers
521 views

Defining 3*(2^4) complex macro at once

An Automata can be 1- or 2- ways, With Several Heads or a Single head Deterministic or Non-deterministic With a stack or not That makes 2^4 = 16 possibilities. However, for each combination, I'd ...
5
votes
1answer
77 views

Renew command on mbox makes it freeze - Fix subscript size

I'm trying to change the font style of \mbox, but all my tries have failed. All commands I try either have no effect or make pdflatex recursively keep working and never finish and freeze. This makes ...
1
vote
1answer
64 views

LaTeX tokenizing

With LaTeX macro \newcommand{\CH}[2]{#1\choose#2} and input \CH63=20 my hope was to get the equivalent of {6\choose3}=20 but I get {6\choose3=20} instead. I know how to fix the text to ...
7
votes
4answers
218 views

auto-detect conditional probabilities in macro

Is it possible to write a macro that detects whether there is a | character in its arguments, and expands that to something else? In concrete terms, I want to be able to use the following definitions ...
7
votes
2answers
194 views

Shortcut to writing out long, common, expressions?

I'm writing an astronomy paper and have some symbols and variables which are common throughout. It's becoming cumbersome to write them out each time. Is there a way to create a shortcut of sorts for ...
4
votes
2answers
137 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
281 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
204 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
40 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
124 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
71 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
93 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
133 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
118 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
169 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
317 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
232 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
111 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
114 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
73 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
134 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
122 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
134 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
135 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 ...
7
votes
2answers
812 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
125 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
64 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
545 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
122 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
56 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
119 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: ...
10
votes
3answers
271 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
36 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
165 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
231 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
650 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
169 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
94 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
162 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
94 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 ...