Math & ScienceShort Syntax for Equation Environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
financialwar
Posts: 29
Joined: Wed Jul 18, 2012 4:55 pm

Short Syntax for Equation Environment

Post by financialwar »

I wonder if the {equation} environment has a short form similar to that of {displaymath} and {math} into $$ and $ respectively?
MiKTex 2.9, Texmaker 3.5 on Windows 7
Learning LaTeX for Finance and Actuarial Studies.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Short Syntax for Equation Environment

Post by localghost »

No. There is no such abbreviation. Perhaps it can be defined similar to the ones you mentioned.

By the way, unnumbered displayed equations should never be introduced by $$ … $$. This is TeX syntax and causes some unwanted side effects. The correct LaTeX syntax is \[ … \].


Thorsten
financialwar
Posts: 29
Joined: Wed Jul 18, 2012 4:55 pm

Short Syntax for Equation Environment

Post by financialwar »

thanks for the reply, I was reading "Guide to LaTeX" by Kopka & Daly, it says that \(...\) is fragile whilst $...$ is robust, what does the author mean by that?

so $$...$$ should be avoided but $...$ is fine?
MiKTex 2.9, Texmaker 3.5 on Windows 7
Learning LaTeX for Finance and Actuarial Studies.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Short Syntax for Equation Environment

Post by cgnieder »

Fragile in LaTeX speak means that a command cannot be used directly in moving arguments (or to be more precise in an expandable context). Typical moving arguments are headings and captions. In the following example the second section line will cause an error (during the second compilation):

Code: Select all

\documentclass{article}

\begin{document}

\tableofcontents
\section{The variable $x$}
\section{The variable \(y\)}
\end{document}
One can circumvent the problem by placing \protect in front of a fragile command inside the moving argument:

Code: Select all

\documentclass{article}

\begin{document}

\tableofcontents
\section{The variable $x$}
\section{The variable \protect\(y\protect\)}
\end{document}
An alternative would be to load etoolbox, use its \robustify and forget about the matter:

Code: Select all

\documentclass{article}
\usepackage{etoolbox}
\robustify\(
\robustify\)
\begin{document}

\tableofcontents
\section{The variable $x$}
\section{The variable \(y\)}
\end{document}
Regards
site moderator & package author
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Short Syntax for Equation Environment

Post by localghost »

cgnieder wrote:[…] n alternative would be to load etoolbox, use its \robustify and forget about the matter: […]
As far as I know the fixltx2e package does this job, too. But it might cause other problems.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Short Syntax for Equation Environment

Post by cgnieder »

localghost wrote:
cgnieder wrote:[…] n alternative would be to load etoolbox, use its \robustify and forget about the matter: […]
As far as I know the fixltx2e package does this job, too. But it might cause other problems.
Indeed, it does! I did not know that, but »fixltx2e« defines a \MakeRobust and contains the lines

Code: Select all

\MakeRobust\(
\MakeRobust\)
The difference to »etoolbox« is that »fixltx2e« protects via the LaTeX2e protection mechanism while »etoolbox« uses eTeX's \protected. This difference once bit me unexpectedly.

Regards
site moderator & package author
financialwar
Posts: 29
Joined: Wed Jul 18, 2012 4:55 pm

Short Syntax for Equation Environment

Post by financialwar »

let me get this straight, it's really confusing for me.

for {math} environment, it is better to use $...$ instead of \(...\) because it is robust and won't cause error in moving arguments.

But for {displaymath} environment, one should use \[...\] instead of $$...$$ because it is TeX syntex?

But isn't $...$ TeX syntex as well?
MiKTex 2.9, Texmaker 3.5 on Windows 7
Learning LaTeX for Finance and Actuarial Studies.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Short Syntax for Equation Environment

Post by Stefan Kottwitz »

Use LaTeX syntax to be consistent at LaTeX level, i.e. \[ ... \] and \( ...\). It's also better to read in the source, because there's an opening command and a closing command. That makes it easier to find a mistake in opening and closing math mode, better than with a lot of $ which open and close.

If you would like to insist on the TeX way,
  • $ ... $ can be used without problems,
  • $$ ... $$ should not be used because of inconsistent vertical spacing.
LaTeX doesn't only introduce new symbols for math environments, it does a bit more.

Stefan
LaTeX.org admin
Post Reply