What are the differences between $$, [, align, equation and displaymath?equation* environment or [...
How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
How can I make my BBEG immortal short of making them a Lich or Vampire?
Example of a continuous function that don't have a continuous extension
Arthur Somervell: 1000 Exercises - Meaning of this notation
Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?
"You are your self first supporter", a more proper way to say it
Do I have a twin with permutated remainders?
Why dont electromagnetic waves interact with each other?
Languages that we cannot (dis)prove to be Context-Free
What do you call a Matrix-like slowdown and camera movement effect?
The use of multiple foreign keys on same column in SQL Server
Python: next in for loop
Why does Kotter return in Welcome Back Kotter?
In Japanese, what’s the difference between “Tonari ni” (となりに) and “Tsugi” (つぎ)? When would you use one over the other?
What does CI-V stand for?
can i play a electric guitar through a bass amp?
Has the BBC provided arguments for saying Brexit being cancelled is unlikely?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
Is it possible to do 50 km distance without any previous training?
Font hinting is lost in Chrome-like browsers (for some languages )
Can divisibility rules for digits be generalized to sum of digits
What is the word for reserving something for yourself before others do?
To string or not to string
What are the differences between $$, [, align, equation and displaymath?
equation* environment or [ ]?Begin{equation} works better with than $$Is `[` equivalent to begin{displaymath}?Unnumbered equations: Any difference between begin{equation*} and [?Difference in the three methods for unnumbered equationWhy is [ … ] preferable to $$ … $$?align vs equationDefining `$$$ $$$` to alignGetting the expectation symbol to behave like $sum$ instead of $Sigma$Can I get $$…$$ to behave like […]?align vs equationalign* but show one equation number at the endAre the [ and begin{equation} used interchangeably?aligned multi-line equation with intertext and block-wise numberingAlign definition of variables of an equation right (not next to the equation)Why would one use the equation environment instead of the align environment?Equation* with split same as align*Align two equation environment blocksHow can I align this equation in the center?Splitting and flushing equations inside align
I once learnt, that it is uncool to use $$
, but why is that? Why does [
not act as a abbreviation to begin{align}
? I noticed, that there is a difference, since one cannot use &
and \
inside a block started with [
.
math-mode equations align amsmath
add a comment |
I once learnt, that it is uncool to use $$
, but why is that? Why does [
not act as a abbreviation to begin{align}
? I noticed, that there is a difference, since one cannot use &
and \
inside a block started with [
.
math-mode equations align amsmath
14
For your first question, see tex.stackexchange.com/questions/503/why-is-preferable-to For the second: tex.stackexchange.com/questions/321/align-vs-equation
– Torbjørn T.
Jan 9 '12 at 6:53
amsmath
has a coherent redefinition of[
. But for some aspects of theLaTeX
[
, see my answer
– user4686
May 19 '14 at 12:33
You should also be using(...)
instead of$...$
too.
– john w.
Jan 20 '15 at 18:49
add a comment |
I once learnt, that it is uncool to use $$
, but why is that? Why does [
not act as a abbreviation to begin{align}
? I noticed, that there is a difference, since one cannot use &
and \
inside a block started with [
.
math-mode equations align amsmath
I once learnt, that it is uncool to use $$
, but why is that? Why does [
not act as a abbreviation to begin{align}
? I noticed, that there is a difference, since one cannot use &
and \
inside a block started with [
.
math-mode equations align amsmath
math-mode equations align amsmath
edited 9 hours ago
David Carlisle
498k4111441892
498k4111441892
asked Jan 9 '12 at 6:32
niklasfiniklasfi
898489
898489
14
For your first question, see tex.stackexchange.com/questions/503/why-is-preferable-to For the second: tex.stackexchange.com/questions/321/align-vs-equation
– Torbjørn T.
Jan 9 '12 at 6:53
amsmath
has a coherent redefinition of[
. But for some aspects of theLaTeX
[
, see my answer
– user4686
May 19 '14 at 12:33
You should also be using(...)
instead of$...$
too.
– john w.
Jan 20 '15 at 18:49
add a comment |
14
For your first question, see tex.stackexchange.com/questions/503/why-is-preferable-to For the second: tex.stackexchange.com/questions/321/align-vs-equation
– Torbjørn T.
Jan 9 '12 at 6:53
amsmath
has a coherent redefinition of[
. But for some aspects of theLaTeX
[
, see my answer
– user4686
May 19 '14 at 12:33
You should also be using(...)
instead of$...$
too.
– john w.
Jan 20 '15 at 18:49
14
14
For your first question, see tex.stackexchange.com/questions/503/why-is-preferable-to For the second: tex.stackexchange.com/questions/321/align-vs-equation
– Torbjørn T.
Jan 9 '12 at 6:53
For your first question, see tex.stackexchange.com/questions/503/why-is-preferable-to For the second: tex.stackexchange.com/questions/321/align-vs-equation
– Torbjørn T.
Jan 9 '12 at 6:53
amsmath
has a coherent redefinition of [
. But for some aspects of the LaTeX
[
, see my answer– user4686
May 19 '14 at 12:33
amsmath
has a coherent redefinition of [
. But for some aspects of the LaTeX
[
, see my answer– user4686
May 19 '14 at 12:33
You should also be using
(...)
instead of $...$
too.– john w.
Jan 20 '15 at 18:49
You should also be using
(...)
instead of $...$
too.– john w.
Jan 20 '15 at 18:49
add a comment |
5 Answers
5
active
oldest
votes
As I understand your question, you'd like to know what the differences are between constructing display-math expressions using the following five methods:
$$
...$$
[
...]
begin{displaymath}
...end{displaymath}
begin{equation}
...end{equation}
begin{gather*}
...end{gather*}
.
Actually, you asked about the align
environment, but I think that for the sake of providing a straightforward comparison among the display-math methods, it's better to focus on the gather*
environment, which centers its contents and doesn't generate an equation number. Compared with the gather
and gather*
environments, the significant added capability of the align
and align*
environments is their ability to vertically align equations along certain elements, such as on equal signs.
The first method is the "Plain TeX" method for generating displayed equations. ("Plain TeX" refers to a set of macros, written by Knuth, designed to make the so-called "TeX primitives" usable for ordinary typesetting purposes. A full explanation of what the $$
specifiers do is provided on p. 287 of the TeXBook.)
However, using the $$
method to initiate and terminate display-math mode in LaTeX documents is nowadays heavily deprecated. See, for instance, the posting "Why is [ ... ] preferable to $$ ... $$?" for a detailed discussion of why one should not employ $$ ... $$
directly when using LaTeX (or one of its successors, such as pdfLaTeX, XeLaTeX, etc).
The second method, [
and ]
, is Leslie Lamport's re-implementation of the Plain-TeX $$
... $$
method. The LaTeX code that defines the [
and ]
commands is contained in the file latex.ltx
:
def[{%
relaxifmmode
@badmath
else
ifvmode
nointerlineskip
makebox[.6linewidth]{}%
fi
$$%%$$ BRACE MATCH HACK
fi
}
def]{%
relaxifmmode
ifinner
@badmath
else
$$%%$$ BRACE MATCH HACK
fi
else
@badmath
fi
ignorespaces
}
Basically, [
and ]
act as carefully designed wrappers around the opening and closing $$
directives. Error messages will be generated if a [
statement is encountered while TeX is already in math mode or if a ]
statement is encountered while not in "outer" (aka "normal") math mode. Aside: What is "inner" math mode? An example of "inner" math mode is the material inside a left( ... right)
pair. If LaTeX encounters ]
before right)
it produces the error message
! LaTeX Error: Bad math environment delimiter.
(If you were using $$
directly you'd get a slightly more cryptic error message.)
Furthermore, the command [
checks if TeX is in so-called "vertical mode". (This happens to be the case, most commonly, at the start of a paragraph.) If that's the case, it avoids inserting some additional vertical space by issuing the command nointerlineskip
. In the following example, a bunch of em-dashes is followed by a blank line (which inserts a paragraph break and switches TeX to vertical mode) and then a displayed equation; in the first case it's generated by [...]
, in the second case by $$...$$
. Note the extra vertical space that's inserted above the second displayed equation.
documentclass{article}
setlengthtextwidth{1in} % use a very narrow measure for this example
begin{document}
noindent
---------------
[ u=vwxz]
---------------
$$u=vwxz$$
---------------
end{document}
The LaTeX code for the third method is simply:
defdisplaymath{[}
defenddisplaymath{]@ignoretrue}
i.e., it is (essentially) equivalent to the second method, while arguably being easier to read and debug. By easier to debug, I mean that these commands are not as easy to overlook as are [
and ]
.
Note that these first three methods do not generate equation numbers.
As implemented in LaTeX -- but without loading the amsmath
package -- the code for the fourth method (begin{equation}
... end{equation}
) is:
@definecounter{equation}
defequation{$$refstepcounter{equation}}
defendequation{eqno hbox{@eqnnum}$$@ignoretrue}
def@eqnnum{{normalfont normalcolor (theequation)}}
This method thus also provides a "wrapper" around the (internally generated) $$
pair of commands, while adding a right-aligned equation number that's surrounded by parentheses. (The eqno
macro is a TeX macro, described on pp. 186-7 and elsewhere in the TeXBook, that inserts an equation number given by @eqnum
.)
However, do note that unlike in the case of [...]
, no test is performed to check whether TeX is in vertical mode when begin{equation}
is executed. Thus, if you start an equation
environment at the start of a paragraph, you may get some extra (and probably unwanted!) vertical space above that equation. This is one of the reasons for the freqently-encountered exhortation never to start a displayed equation at the start of a paragraph.
Finally, about the begin{gather*}
... end{gather*}
method that's made available by loading the amsmath
package. Before examining the details of this method, it's important to mention that the amsmath
package provides the commands mathdisplay
and endmathdisplay
, which serve as (even more elaborate) "wrappers" around -- you guessed it -- the plain-TeX $$
constructs. The amsmath
package provides a redefinition of the equation
environment and a new environment for unnumbered equations called equation*
:
renewenvironment{equation}{%
incr@eqnum
mathdisplay@push
st@rredfalse global@eqnswtrue
mathdisplay{equation}%
}{%
endmathdisplay{equation}%
mathdisplay@pop
ignorespacesafterend
}
newenvironment{equation*}{%
mathdisplay@push
st@rredtrue global@eqnswfalse
mathdisplay{equation*}%
}{%
endmathdisplay{equation*}%
mathdisplay@pop
ignorespacesafterend
}
As you can see, the equation
and equation*
environments eventually call the mathdisplay
and endmathdisplay
commands, which, in turn, call the TeX $$
macros. Incidentally, amsmath
also redefines the LaTeX commands [
and ]
as follows:
DeclareRobustCommand{[}{begin{equation*}}
DeclareRobustCommand{]}{end{equation*}}
(Observe that because displaymath
is defined in terms of the [
and ]
commands, its appearance too may change when used in combination with the amsmath
package.)
On, then, to the code for the gather*
environment:
newenvironment{gather*}{%
start@gatherst@rredtrue
}{%
endgather
}
where the start@gather
command is defined as
defstart@gather#1{%
RIfM@
nomath@env
DN@{@namedef{end@currenvir}{}@gobble}%
else
$$%
#1%
ifst@rred else global@eqnswtrue fi
letnext@gather@
fi
collect@bodynext@
}
The command endgather
, which is defined implicitly, executes the following instructions:
math@cr black@totwidth@ egroup
$$ignorespacesafterend
The main thing to take away from examining these lines of code -- without going into too many of the details, many of which relate to the fact that the align, align*, gather, gather*, etc environments can typeset multiple, consecutive lines of displayed-math material -- is that the gather*
environment too (eventually) calls the $$
TeX macro, while taking care of quite a few housekeeping and error-avoidance steps along the way.
In sum, one thing that should be amply clear from all this is that using the $$
constructs directly is unnecessary and even reckless, as doing so risks causing all kinds of messy screw-ups. The alternative methods 2 through 5 take care to avoid these problems and should therefore always be preferred to using the $$
pair of commands.
Your link seems to be broken.
– celtschk
Jan 9 '12 at 20:07
@celtschk: Thanks for pointing out the problem; I've fixed the link.
– Mico
Jan 9 '12 at 20:12
@Mico you saidIf that's the case, it avoids inserting any additional vertical space by issuing the command nointerlineskip.
. But quite to the contrary, LaTeX then issues an empty line adding vertical space and forcing the use of the long form of the above and below display skips.
– user4686
May 19 '14 at 11:39
1
@Mico why do not the reasons disqualifying$$
also disqualifybegin{equation}
? why isn't[
coherent in vertical spacing withbegin{equation}
?
– user4686
May 19 '14 at 11:52
1
@Mico your example with the extra vertical space above a$$
encountered in vertical mode is not convincing becausenointerlineskip$$
fixes the issue. But[
does a bit more thannointerlineskip
it creates a horzontal box of width.6linewidth
and this can NOT be undone!
– user4686
May 19 '14 at 19:47
|
show 4 more comments
$$
is not supported in LaTeX at all, it is primitive TeX syntax that just happens to sort of almost work most of the time. The standard LaTeX classes for example all have a fleqn
option to align rather than center [ ]
. Even with no options, the behaviour of [
and $$
are different at the start of a paragraph, where [
does
nointerlineskip
makebox[.6linewidth]{}%
before doing $$
thanks for editing, was just looking up the quote syntax, and by the time I came back you'd fixed it:-)
– David Carlisle
Jan 9 '12 at 10:21
2
Welcome back to TeX.SX!
– egreg
Jan 9 '12 at 15:10
add a comment |
The differences have been described, in earlier answers, I am just adding here for illustrative purposes regarding vertical spaces this image:
which is obtained from this code:
documentclass{article}
begin{document}
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
end{document}
Notice the vertical spaces added by the [..]
construct, which furthermore are asymmetrical between before and after. Apart from that the [..]
does some error checking whose usefulness, IMHO, is limited to the real beginners in LaTeX
.
Here is another image:
obtained from this code:
documentclass{article}
begin{document}
noindent
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
end{document}
Notice the incoherent vertical spacing resulting from the use of [..]
.
I do not include the images here, but one can check that these incoherencies do disappear with usepackage{amsmath}
(for reasons which are clear from looking at the code reproduced in Mico's answer). I know my opinion is ultra-minoritarian, but clearly, only for people using amsmath
can one convincingly argue it is better to not use $$
directly.
Certainly $$
is not in the spirit of the LaTeX
syntax, but the [
in LaTeX2e
is not coherent with the other math environment in its handling of vertical spacing. Thus, I personnally concluded that when I am not loading amsmath
, I should rather avoid [
.
1
can I offer a bounty to the first upvoter?
– user4686
May 19 '14 at 12:36
1
OK, I've upvoted your answer. :-)
– Mico
May 19 '14 at 13:00
I think neither your examples invalidates the claim that[
-- unlike$$
-- takes care to avoid inserting an extra blank line if it's encountered while TeX is in vertical mode. In your first example, note that TeX is not in vertical mode at the end ofhrule
, hence there's no issue with$$
inadvisedly slipping in an extra blank line. Replace thehrule
andhrulefill
directives with a bunch of em-dashes, and it becomes quite apparent that the equation is nicely centered (between the rows of em-dashes) if it's typeset with[ ... ]
but not if it's typeset via$$...$$
.
– Mico
May 19 '14 at 13:15
@Mico are you sure? try replacinghrule
withhruleifvmode typeout{VMODE}else typeout{NOT VMODE}fi
and check the log. Andhrulefill
is followed bypar
. It is true that after]
or$$
,TeX
is in horizontal mode but this is another issue. I will check what you mean with the em-dashes.
– user4686
May 19 '14 at 13:55
@Mico I have replaced in my code samplehrule
by 15 successivetextemdash
es and then, as expected, because we start in horizontal mode, both[..]
and$$..$$
give the exact same result. (by the way I have upvoted your comment about upvoting my answer;-)
)
– user4686
May 19 '14 at 14:00
|
show 3 more comments
Also align
does not behave the same way as [...]
regards to spacing before. [...]
and the equation
environment can adjust the spacing above the equation if there is enough
room, align
cannot (because of the manner in which it is constructed)
1
An example of this spacing difference can be found at align vs equation.
– Peter Grill
Jan 9 '12 at 20:20
And what is the difference between[...]
and(...)
.
– jafan
Nov 15 '13 at 18:13
1
The first is displayed math the other is a slight alternative to $... $
– daleif
Nov 15 '13 at 22:53
add a comment |
An additional answer that is one of the most important for me: the cleveref
package will automatically handle an equation contained in begin{equation}
but not [
.
5
Equations using[...]
are not numbered, and so the concept ofref
has no meaning in this context.
– Steven B. Segletes
Jan 30 '17 at 14:24
Your posting appears to apply to all unnumbered environments, not justequation
-type environments. For thelabel
-ref
(orlabel
-cref
) mechanism to "work", the object (say, anequation
environment) that's beinglabel
-ed has to be associated with a counter variable that's being incremented (either by the environment itself or via a command such ascaption
). Since[ ...]
, by design, does not increment any counters, it's not possible to use theref
orcref
to create cross-references to the non-existent equation numbers.
– Mico
Jan 30 '17 at 15:41
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f40492%2fwhat-are-the-differences-between-align-equation-and-displaymath%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
As I understand your question, you'd like to know what the differences are between constructing display-math expressions using the following five methods:
$$
...$$
[
...]
begin{displaymath}
...end{displaymath}
begin{equation}
...end{equation}
begin{gather*}
...end{gather*}
.
Actually, you asked about the align
environment, but I think that for the sake of providing a straightforward comparison among the display-math methods, it's better to focus on the gather*
environment, which centers its contents and doesn't generate an equation number. Compared with the gather
and gather*
environments, the significant added capability of the align
and align*
environments is their ability to vertically align equations along certain elements, such as on equal signs.
The first method is the "Plain TeX" method for generating displayed equations. ("Plain TeX" refers to a set of macros, written by Knuth, designed to make the so-called "TeX primitives" usable for ordinary typesetting purposes. A full explanation of what the $$
specifiers do is provided on p. 287 of the TeXBook.)
However, using the $$
method to initiate and terminate display-math mode in LaTeX documents is nowadays heavily deprecated. See, for instance, the posting "Why is [ ... ] preferable to $$ ... $$?" for a detailed discussion of why one should not employ $$ ... $$
directly when using LaTeX (or one of its successors, such as pdfLaTeX, XeLaTeX, etc).
The second method, [
and ]
, is Leslie Lamport's re-implementation of the Plain-TeX $$
... $$
method. The LaTeX code that defines the [
and ]
commands is contained in the file latex.ltx
:
def[{%
relaxifmmode
@badmath
else
ifvmode
nointerlineskip
makebox[.6linewidth]{}%
fi
$$%%$$ BRACE MATCH HACK
fi
}
def]{%
relaxifmmode
ifinner
@badmath
else
$$%%$$ BRACE MATCH HACK
fi
else
@badmath
fi
ignorespaces
}
Basically, [
and ]
act as carefully designed wrappers around the opening and closing $$
directives. Error messages will be generated if a [
statement is encountered while TeX is already in math mode or if a ]
statement is encountered while not in "outer" (aka "normal") math mode. Aside: What is "inner" math mode? An example of "inner" math mode is the material inside a left( ... right)
pair. If LaTeX encounters ]
before right)
it produces the error message
! LaTeX Error: Bad math environment delimiter.
(If you were using $$
directly you'd get a slightly more cryptic error message.)
Furthermore, the command [
checks if TeX is in so-called "vertical mode". (This happens to be the case, most commonly, at the start of a paragraph.) If that's the case, it avoids inserting some additional vertical space by issuing the command nointerlineskip
. In the following example, a bunch of em-dashes is followed by a blank line (which inserts a paragraph break and switches TeX to vertical mode) and then a displayed equation; in the first case it's generated by [...]
, in the second case by $$...$$
. Note the extra vertical space that's inserted above the second displayed equation.
documentclass{article}
setlengthtextwidth{1in} % use a very narrow measure for this example
begin{document}
noindent
---------------
[ u=vwxz]
---------------
$$u=vwxz$$
---------------
end{document}
The LaTeX code for the third method is simply:
defdisplaymath{[}
defenddisplaymath{]@ignoretrue}
i.e., it is (essentially) equivalent to the second method, while arguably being easier to read and debug. By easier to debug, I mean that these commands are not as easy to overlook as are [
and ]
.
Note that these first three methods do not generate equation numbers.
As implemented in LaTeX -- but without loading the amsmath
package -- the code for the fourth method (begin{equation}
... end{equation}
) is:
@definecounter{equation}
defequation{$$refstepcounter{equation}}
defendequation{eqno hbox{@eqnnum}$$@ignoretrue}
def@eqnnum{{normalfont normalcolor (theequation)}}
This method thus also provides a "wrapper" around the (internally generated) $$
pair of commands, while adding a right-aligned equation number that's surrounded by parentheses. (The eqno
macro is a TeX macro, described on pp. 186-7 and elsewhere in the TeXBook, that inserts an equation number given by @eqnum
.)
However, do note that unlike in the case of [...]
, no test is performed to check whether TeX is in vertical mode when begin{equation}
is executed. Thus, if you start an equation
environment at the start of a paragraph, you may get some extra (and probably unwanted!) vertical space above that equation. This is one of the reasons for the freqently-encountered exhortation never to start a displayed equation at the start of a paragraph.
Finally, about the begin{gather*}
... end{gather*}
method that's made available by loading the amsmath
package. Before examining the details of this method, it's important to mention that the amsmath
package provides the commands mathdisplay
and endmathdisplay
, which serve as (even more elaborate) "wrappers" around -- you guessed it -- the plain-TeX $$
constructs. The amsmath
package provides a redefinition of the equation
environment and a new environment for unnumbered equations called equation*
:
renewenvironment{equation}{%
incr@eqnum
mathdisplay@push
st@rredfalse global@eqnswtrue
mathdisplay{equation}%
}{%
endmathdisplay{equation}%
mathdisplay@pop
ignorespacesafterend
}
newenvironment{equation*}{%
mathdisplay@push
st@rredtrue global@eqnswfalse
mathdisplay{equation*}%
}{%
endmathdisplay{equation*}%
mathdisplay@pop
ignorespacesafterend
}
As you can see, the equation
and equation*
environments eventually call the mathdisplay
and endmathdisplay
commands, which, in turn, call the TeX $$
macros. Incidentally, amsmath
also redefines the LaTeX commands [
and ]
as follows:
DeclareRobustCommand{[}{begin{equation*}}
DeclareRobustCommand{]}{end{equation*}}
(Observe that because displaymath
is defined in terms of the [
and ]
commands, its appearance too may change when used in combination with the amsmath
package.)
On, then, to the code for the gather*
environment:
newenvironment{gather*}{%
start@gatherst@rredtrue
}{%
endgather
}
where the start@gather
command is defined as
defstart@gather#1{%
RIfM@
nomath@env
DN@{@namedef{end@currenvir}{}@gobble}%
else
$$%
#1%
ifst@rred else global@eqnswtrue fi
letnext@gather@
fi
collect@bodynext@
}
The command endgather
, which is defined implicitly, executes the following instructions:
math@cr black@totwidth@ egroup
$$ignorespacesafterend
The main thing to take away from examining these lines of code -- without going into too many of the details, many of which relate to the fact that the align, align*, gather, gather*, etc environments can typeset multiple, consecutive lines of displayed-math material -- is that the gather*
environment too (eventually) calls the $$
TeX macro, while taking care of quite a few housekeeping and error-avoidance steps along the way.
In sum, one thing that should be amply clear from all this is that using the $$
constructs directly is unnecessary and even reckless, as doing so risks causing all kinds of messy screw-ups. The alternative methods 2 through 5 take care to avoid these problems and should therefore always be preferred to using the $$
pair of commands.
Your link seems to be broken.
– celtschk
Jan 9 '12 at 20:07
@celtschk: Thanks for pointing out the problem; I've fixed the link.
– Mico
Jan 9 '12 at 20:12
@Mico you saidIf that's the case, it avoids inserting any additional vertical space by issuing the command nointerlineskip.
. But quite to the contrary, LaTeX then issues an empty line adding vertical space and forcing the use of the long form of the above and below display skips.
– user4686
May 19 '14 at 11:39
1
@Mico why do not the reasons disqualifying$$
also disqualifybegin{equation}
? why isn't[
coherent in vertical spacing withbegin{equation}
?
– user4686
May 19 '14 at 11:52
1
@Mico your example with the extra vertical space above a$$
encountered in vertical mode is not convincing becausenointerlineskip$$
fixes the issue. But[
does a bit more thannointerlineskip
it creates a horzontal box of width.6linewidth
and this can NOT be undone!
– user4686
May 19 '14 at 19:47
|
show 4 more comments
As I understand your question, you'd like to know what the differences are between constructing display-math expressions using the following five methods:
$$
...$$
[
...]
begin{displaymath}
...end{displaymath}
begin{equation}
...end{equation}
begin{gather*}
...end{gather*}
.
Actually, you asked about the align
environment, but I think that for the sake of providing a straightforward comparison among the display-math methods, it's better to focus on the gather*
environment, which centers its contents and doesn't generate an equation number. Compared with the gather
and gather*
environments, the significant added capability of the align
and align*
environments is their ability to vertically align equations along certain elements, such as on equal signs.
The first method is the "Plain TeX" method for generating displayed equations. ("Plain TeX" refers to a set of macros, written by Knuth, designed to make the so-called "TeX primitives" usable for ordinary typesetting purposes. A full explanation of what the $$
specifiers do is provided on p. 287 of the TeXBook.)
However, using the $$
method to initiate and terminate display-math mode in LaTeX documents is nowadays heavily deprecated. See, for instance, the posting "Why is [ ... ] preferable to $$ ... $$?" for a detailed discussion of why one should not employ $$ ... $$
directly when using LaTeX (or one of its successors, such as pdfLaTeX, XeLaTeX, etc).
The second method, [
and ]
, is Leslie Lamport's re-implementation of the Plain-TeX $$
... $$
method. The LaTeX code that defines the [
and ]
commands is contained in the file latex.ltx
:
def[{%
relaxifmmode
@badmath
else
ifvmode
nointerlineskip
makebox[.6linewidth]{}%
fi
$$%%$$ BRACE MATCH HACK
fi
}
def]{%
relaxifmmode
ifinner
@badmath
else
$$%%$$ BRACE MATCH HACK
fi
else
@badmath
fi
ignorespaces
}
Basically, [
and ]
act as carefully designed wrappers around the opening and closing $$
directives. Error messages will be generated if a [
statement is encountered while TeX is already in math mode or if a ]
statement is encountered while not in "outer" (aka "normal") math mode. Aside: What is "inner" math mode? An example of "inner" math mode is the material inside a left( ... right)
pair. If LaTeX encounters ]
before right)
it produces the error message
! LaTeX Error: Bad math environment delimiter.
(If you were using $$
directly you'd get a slightly more cryptic error message.)
Furthermore, the command [
checks if TeX is in so-called "vertical mode". (This happens to be the case, most commonly, at the start of a paragraph.) If that's the case, it avoids inserting some additional vertical space by issuing the command nointerlineskip
. In the following example, a bunch of em-dashes is followed by a blank line (which inserts a paragraph break and switches TeX to vertical mode) and then a displayed equation; in the first case it's generated by [...]
, in the second case by $$...$$
. Note the extra vertical space that's inserted above the second displayed equation.
documentclass{article}
setlengthtextwidth{1in} % use a very narrow measure for this example
begin{document}
noindent
---------------
[ u=vwxz]
---------------
$$u=vwxz$$
---------------
end{document}
The LaTeX code for the third method is simply:
defdisplaymath{[}
defenddisplaymath{]@ignoretrue}
i.e., it is (essentially) equivalent to the second method, while arguably being easier to read and debug. By easier to debug, I mean that these commands are not as easy to overlook as are [
and ]
.
Note that these first three methods do not generate equation numbers.
As implemented in LaTeX -- but without loading the amsmath
package -- the code for the fourth method (begin{equation}
... end{equation}
) is:
@definecounter{equation}
defequation{$$refstepcounter{equation}}
defendequation{eqno hbox{@eqnnum}$$@ignoretrue}
def@eqnnum{{normalfont normalcolor (theequation)}}
This method thus also provides a "wrapper" around the (internally generated) $$
pair of commands, while adding a right-aligned equation number that's surrounded by parentheses. (The eqno
macro is a TeX macro, described on pp. 186-7 and elsewhere in the TeXBook, that inserts an equation number given by @eqnum
.)
However, do note that unlike in the case of [...]
, no test is performed to check whether TeX is in vertical mode when begin{equation}
is executed. Thus, if you start an equation
environment at the start of a paragraph, you may get some extra (and probably unwanted!) vertical space above that equation. This is one of the reasons for the freqently-encountered exhortation never to start a displayed equation at the start of a paragraph.
Finally, about the begin{gather*}
... end{gather*}
method that's made available by loading the amsmath
package. Before examining the details of this method, it's important to mention that the amsmath
package provides the commands mathdisplay
and endmathdisplay
, which serve as (even more elaborate) "wrappers" around -- you guessed it -- the plain-TeX $$
constructs. The amsmath
package provides a redefinition of the equation
environment and a new environment for unnumbered equations called equation*
:
renewenvironment{equation}{%
incr@eqnum
mathdisplay@push
st@rredfalse global@eqnswtrue
mathdisplay{equation}%
}{%
endmathdisplay{equation}%
mathdisplay@pop
ignorespacesafterend
}
newenvironment{equation*}{%
mathdisplay@push
st@rredtrue global@eqnswfalse
mathdisplay{equation*}%
}{%
endmathdisplay{equation*}%
mathdisplay@pop
ignorespacesafterend
}
As you can see, the equation
and equation*
environments eventually call the mathdisplay
and endmathdisplay
commands, which, in turn, call the TeX $$
macros. Incidentally, amsmath
also redefines the LaTeX commands [
and ]
as follows:
DeclareRobustCommand{[}{begin{equation*}}
DeclareRobustCommand{]}{end{equation*}}
(Observe that because displaymath
is defined in terms of the [
and ]
commands, its appearance too may change when used in combination with the amsmath
package.)
On, then, to the code for the gather*
environment:
newenvironment{gather*}{%
start@gatherst@rredtrue
}{%
endgather
}
where the start@gather
command is defined as
defstart@gather#1{%
RIfM@
nomath@env
DN@{@namedef{end@currenvir}{}@gobble}%
else
$$%
#1%
ifst@rred else global@eqnswtrue fi
letnext@gather@
fi
collect@bodynext@
}
The command endgather
, which is defined implicitly, executes the following instructions:
math@cr black@totwidth@ egroup
$$ignorespacesafterend
The main thing to take away from examining these lines of code -- without going into too many of the details, many of which relate to the fact that the align, align*, gather, gather*, etc environments can typeset multiple, consecutive lines of displayed-math material -- is that the gather*
environment too (eventually) calls the $$
TeX macro, while taking care of quite a few housekeeping and error-avoidance steps along the way.
In sum, one thing that should be amply clear from all this is that using the $$
constructs directly is unnecessary and even reckless, as doing so risks causing all kinds of messy screw-ups. The alternative methods 2 through 5 take care to avoid these problems and should therefore always be preferred to using the $$
pair of commands.
Your link seems to be broken.
– celtschk
Jan 9 '12 at 20:07
@celtschk: Thanks for pointing out the problem; I've fixed the link.
– Mico
Jan 9 '12 at 20:12
@Mico you saidIf that's the case, it avoids inserting any additional vertical space by issuing the command nointerlineskip.
. But quite to the contrary, LaTeX then issues an empty line adding vertical space and forcing the use of the long form of the above and below display skips.
– user4686
May 19 '14 at 11:39
1
@Mico why do not the reasons disqualifying$$
also disqualifybegin{equation}
? why isn't[
coherent in vertical spacing withbegin{equation}
?
– user4686
May 19 '14 at 11:52
1
@Mico your example with the extra vertical space above a$$
encountered in vertical mode is not convincing becausenointerlineskip$$
fixes the issue. But[
does a bit more thannointerlineskip
it creates a horzontal box of width.6linewidth
and this can NOT be undone!
– user4686
May 19 '14 at 19:47
|
show 4 more comments
As I understand your question, you'd like to know what the differences are between constructing display-math expressions using the following five methods:
$$
...$$
[
...]
begin{displaymath}
...end{displaymath}
begin{equation}
...end{equation}
begin{gather*}
...end{gather*}
.
Actually, you asked about the align
environment, but I think that for the sake of providing a straightforward comparison among the display-math methods, it's better to focus on the gather*
environment, which centers its contents and doesn't generate an equation number. Compared with the gather
and gather*
environments, the significant added capability of the align
and align*
environments is their ability to vertically align equations along certain elements, such as on equal signs.
The first method is the "Plain TeX" method for generating displayed equations. ("Plain TeX" refers to a set of macros, written by Knuth, designed to make the so-called "TeX primitives" usable for ordinary typesetting purposes. A full explanation of what the $$
specifiers do is provided on p. 287 of the TeXBook.)
However, using the $$
method to initiate and terminate display-math mode in LaTeX documents is nowadays heavily deprecated. See, for instance, the posting "Why is [ ... ] preferable to $$ ... $$?" for a detailed discussion of why one should not employ $$ ... $$
directly when using LaTeX (or one of its successors, such as pdfLaTeX, XeLaTeX, etc).
The second method, [
and ]
, is Leslie Lamport's re-implementation of the Plain-TeX $$
... $$
method. The LaTeX code that defines the [
and ]
commands is contained in the file latex.ltx
:
def[{%
relaxifmmode
@badmath
else
ifvmode
nointerlineskip
makebox[.6linewidth]{}%
fi
$$%%$$ BRACE MATCH HACK
fi
}
def]{%
relaxifmmode
ifinner
@badmath
else
$$%%$$ BRACE MATCH HACK
fi
else
@badmath
fi
ignorespaces
}
Basically, [
and ]
act as carefully designed wrappers around the opening and closing $$
directives. Error messages will be generated if a [
statement is encountered while TeX is already in math mode or if a ]
statement is encountered while not in "outer" (aka "normal") math mode. Aside: What is "inner" math mode? An example of "inner" math mode is the material inside a left( ... right)
pair. If LaTeX encounters ]
before right)
it produces the error message
! LaTeX Error: Bad math environment delimiter.
(If you were using $$
directly you'd get a slightly more cryptic error message.)
Furthermore, the command [
checks if TeX is in so-called "vertical mode". (This happens to be the case, most commonly, at the start of a paragraph.) If that's the case, it avoids inserting some additional vertical space by issuing the command nointerlineskip
. In the following example, a bunch of em-dashes is followed by a blank line (which inserts a paragraph break and switches TeX to vertical mode) and then a displayed equation; in the first case it's generated by [...]
, in the second case by $$...$$
. Note the extra vertical space that's inserted above the second displayed equation.
documentclass{article}
setlengthtextwidth{1in} % use a very narrow measure for this example
begin{document}
noindent
---------------
[ u=vwxz]
---------------
$$u=vwxz$$
---------------
end{document}
The LaTeX code for the third method is simply:
defdisplaymath{[}
defenddisplaymath{]@ignoretrue}
i.e., it is (essentially) equivalent to the second method, while arguably being easier to read and debug. By easier to debug, I mean that these commands are not as easy to overlook as are [
and ]
.
Note that these first three methods do not generate equation numbers.
As implemented in LaTeX -- but without loading the amsmath
package -- the code for the fourth method (begin{equation}
... end{equation}
) is:
@definecounter{equation}
defequation{$$refstepcounter{equation}}
defendequation{eqno hbox{@eqnnum}$$@ignoretrue}
def@eqnnum{{normalfont normalcolor (theequation)}}
This method thus also provides a "wrapper" around the (internally generated) $$
pair of commands, while adding a right-aligned equation number that's surrounded by parentheses. (The eqno
macro is a TeX macro, described on pp. 186-7 and elsewhere in the TeXBook, that inserts an equation number given by @eqnum
.)
However, do note that unlike in the case of [...]
, no test is performed to check whether TeX is in vertical mode when begin{equation}
is executed. Thus, if you start an equation
environment at the start of a paragraph, you may get some extra (and probably unwanted!) vertical space above that equation. This is one of the reasons for the freqently-encountered exhortation never to start a displayed equation at the start of a paragraph.
Finally, about the begin{gather*}
... end{gather*}
method that's made available by loading the amsmath
package. Before examining the details of this method, it's important to mention that the amsmath
package provides the commands mathdisplay
and endmathdisplay
, which serve as (even more elaborate) "wrappers" around -- you guessed it -- the plain-TeX $$
constructs. The amsmath
package provides a redefinition of the equation
environment and a new environment for unnumbered equations called equation*
:
renewenvironment{equation}{%
incr@eqnum
mathdisplay@push
st@rredfalse global@eqnswtrue
mathdisplay{equation}%
}{%
endmathdisplay{equation}%
mathdisplay@pop
ignorespacesafterend
}
newenvironment{equation*}{%
mathdisplay@push
st@rredtrue global@eqnswfalse
mathdisplay{equation*}%
}{%
endmathdisplay{equation*}%
mathdisplay@pop
ignorespacesafterend
}
As you can see, the equation
and equation*
environments eventually call the mathdisplay
and endmathdisplay
commands, which, in turn, call the TeX $$
macros. Incidentally, amsmath
also redefines the LaTeX commands [
and ]
as follows:
DeclareRobustCommand{[}{begin{equation*}}
DeclareRobustCommand{]}{end{equation*}}
(Observe that because displaymath
is defined in terms of the [
and ]
commands, its appearance too may change when used in combination with the amsmath
package.)
On, then, to the code for the gather*
environment:
newenvironment{gather*}{%
start@gatherst@rredtrue
}{%
endgather
}
where the start@gather
command is defined as
defstart@gather#1{%
RIfM@
nomath@env
DN@{@namedef{end@currenvir}{}@gobble}%
else
$$%
#1%
ifst@rred else global@eqnswtrue fi
letnext@gather@
fi
collect@bodynext@
}
The command endgather
, which is defined implicitly, executes the following instructions:
math@cr black@totwidth@ egroup
$$ignorespacesafterend
The main thing to take away from examining these lines of code -- without going into too many of the details, many of which relate to the fact that the align, align*, gather, gather*, etc environments can typeset multiple, consecutive lines of displayed-math material -- is that the gather*
environment too (eventually) calls the $$
TeX macro, while taking care of quite a few housekeeping and error-avoidance steps along the way.
In sum, one thing that should be amply clear from all this is that using the $$
constructs directly is unnecessary and even reckless, as doing so risks causing all kinds of messy screw-ups. The alternative methods 2 through 5 take care to avoid these problems and should therefore always be preferred to using the $$
pair of commands.
As I understand your question, you'd like to know what the differences are between constructing display-math expressions using the following five methods:
$$
...$$
[
...]
begin{displaymath}
...end{displaymath}
begin{equation}
...end{equation}
begin{gather*}
...end{gather*}
.
Actually, you asked about the align
environment, but I think that for the sake of providing a straightforward comparison among the display-math methods, it's better to focus on the gather*
environment, which centers its contents and doesn't generate an equation number. Compared with the gather
and gather*
environments, the significant added capability of the align
and align*
environments is their ability to vertically align equations along certain elements, such as on equal signs.
The first method is the "Plain TeX" method for generating displayed equations. ("Plain TeX" refers to a set of macros, written by Knuth, designed to make the so-called "TeX primitives" usable for ordinary typesetting purposes. A full explanation of what the $$
specifiers do is provided on p. 287 of the TeXBook.)
However, using the $$
method to initiate and terminate display-math mode in LaTeX documents is nowadays heavily deprecated. See, for instance, the posting "Why is [ ... ] preferable to $$ ... $$?" for a detailed discussion of why one should not employ $$ ... $$
directly when using LaTeX (or one of its successors, such as pdfLaTeX, XeLaTeX, etc).
The second method, [
and ]
, is Leslie Lamport's re-implementation of the Plain-TeX $$
... $$
method. The LaTeX code that defines the [
and ]
commands is contained in the file latex.ltx
:
def[{%
relaxifmmode
@badmath
else
ifvmode
nointerlineskip
makebox[.6linewidth]{}%
fi
$$%%$$ BRACE MATCH HACK
fi
}
def]{%
relaxifmmode
ifinner
@badmath
else
$$%%$$ BRACE MATCH HACK
fi
else
@badmath
fi
ignorespaces
}
Basically, [
and ]
act as carefully designed wrappers around the opening and closing $$
directives. Error messages will be generated if a [
statement is encountered while TeX is already in math mode or if a ]
statement is encountered while not in "outer" (aka "normal") math mode. Aside: What is "inner" math mode? An example of "inner" math mode is the material inside a left( ... right)
pair. If LaTeX encounters ]
before right)
it produces the error message
! LaTeX Error: Bad math environment delimiter.
(If you were using $$
directly you'd get a slightly more cryptic error message.)
Furthermore, the command [
checks if TeX is in so-called "vertical mode". (This happens to be the case, most commonly, at the start of a paragraph.) If that's the case, it avoids inserting some additional vertical space by issuing the command nointerlineskip
. In the following example, a bunch of em-dashes is followed by a blank line (which inserts a paragraph break and switches TeX to vertical mode) and then a displayed equation; in the first case it's generated by [...]
, in the second case by $$...$$
. Note the extra vertical space that's inserted above the second displayed equation.
documentclass{article}
setlengthtextwidth{1in} % use a very narrow measure for this example
begin{document}
noindent
---------------
[ u=vwxz]
---------------
$$u=vwxz$$
---------------
end{document}
The LaTeX code for the third method is simply:
defdisplaymath{[}
defenddisplaymath{]@ignoretrue}
i.e., it is (essentially) equivalent to the second method, while arguably being easier to read and debug. By easier to debug, I mean that these commands are not as easy to overlook as are [
and ]
.
Note that these first three methods do not generate equation numbers.
As implemented in LaTeX -- but without loading the amsmath
package -- the code for the fourth method (begin{equation}
... end{equation}
) is:
@definecounter{equation}
defequation{$$refstepcounter{equation}}
defendequation{eqno hbox{@eqnnum}$$@ignoretrue}
def@eqnnum{{normalfont normalcolor (theequation)}}
This method thus also provides a "wrapper" around the (internally generated) $$
pair of commands, while adding a right-aligned equation number that's surrounded by parentheses. (The eqno
macro is a TeX macro, described on pp. 186-7 and elsewhere in the TeXBook, that inserts an equation number given by @eqnum
.)
However, do note that unlike in the case of [...]
, no test is performed to check whether TeX is in vertical mode when begin{equation}
is executed. Thus, if you start an equation
environment at the start of a paragraph, you may get some extra (and probably unwanted!) vertical space above that equation. This is one of the reasons for the freqently-encountered exhortation never to start a displayed equation at the start of a paragraph.
Finally, about the begin{gather*}
... end{gather*}
method that's made available by loading the amsmath
package. Before examining the details of this method, it's important to mention that the amsmath
package provides the commands mathdisplay
and endmathdisplay
, which serve as (even more elaborate) "wrappers" around -- you guessed it -- the plain-TeX $$
constructs. The amsmath
package provides a redefinition of the equation
environment and a new environment for unnumbered equations called equation*
:
renewenvironment{equation}{%
incr@eqnum
mathdisplay@push
st@rredfalse global@eqnswtrue
mathdisplay{equation}%
}{%
endmathdisplay{equation}%
mathdisplay@pop
ignorespacesafterend
}
newenvironment{equation*}{%
mathdisplay@push
st@rredtrue global@eqnswfalse
mathdisplay{equation*}%
}{%
endmathdisplay{equation*}%
mathdisplay@pop
ignorespacesafterend
}
As you can see, the equation
and equation*
environments eventually call the mathdisplay
and endmathdisplay
commands, which, in turn, call the TeX $$
macros. Incidentally, amsmath
also redefines the LaTeX commands [
and ]
as follows:
DeclareRobustCommand{[}{begin{equation*}}
DeclareRobustCommand{]}{end{equation*}}
(Observe that because displaymath
is defined in terms of the [
and ]
commands, its appearance too may change when used in combination with the amsmath
package.)
On, then, to the code for the gather*
environment:
newenvironment{gather*}{%
start@gatherst@rredtrue
}{%
endgather
}
where the start@gather
command is defined as
defstart@gather#1{%
RIfM@
nomath@env
DN@{@namedef{end@currenvir}{}@gobble}%
else
$$%
#1%
ifst@rred else global@eqnswtrue fi
letnext@gather@
fi
collect@bodynext@
}
The command endgather
, which is defined implicitly, executes the following instructions:
math@cr black@totwidth@ egroup
$$ignorespacesafterend
The main thing to take away from examining these lines of code -- without going into too many of the details, many of which relate to the fact that the align, align*, gather, gather*, etc environments can typeset multiple, consecutive lines of displayed-math material -- is that the gather*
environment too (eventually) calls the $$
TeX macro, while taking care of quite a few housekeeping and error-avoidance steps along the way.
In sum, one thing that should be amply clear from all this is that using the $$
constructs directly is unnecessary and even reckless, as doing so risks causing all kinds of messy screw-ups. The alternative methods 2 through 5 take care to avoid these problems and should therefore always be preferred to using the $$
pair of commands.
edited Apr 13 '17 at 12:35
Community♦
1
1
answered Jan 9 '12 at 14:44
MicoMico
285k32388778
285k32388778
Your link seems to be broken.
– celtschk
Jan 9 '12 at 20:07
@celtschk: Thanks for pointing out the problem; I've fixed the link.
– Mico
Jan 9 '12 at 20:12
@Mico you saidIf that's the case, it avoids inserting any additional vertical space by issuing the command nointerlineskip.
. But quite to the contrary, LaTeX then issues an empty line adding vertical space and forcing the use of the long form of the above and below display skips.
– user4686
May 19 '14 at 11:39
1
@Mico why do not the reasons disqualifying$$
also disqualifybegin{equation}
? why isn't[
coherent in vertical spacing withbegin{equation}
?
– user4686
May 19 '14 at 11:52
1
@Mico your example with the extra vertical space above a$$
encountered in vertical mode is not convincing becausenointerlineskip$$
fixes the issue. But[
does a bit more thannointerlineskip
it creates a horzontal box of width.6linewidth
and this can NOT be undone!
– user4686
May 19 '14 at 19:47
|
show 4 more comments
Your link seems to be broken.
– celtschk
Jan 9 '12 at 20:07
@celtschk: Thanks for pointing out the problem; I've fixed the link.
– Mico
Jan 9 '12 at 20:12
@Mico you saidIf that's the case, it avoids inserting any additional vertical space by issuing the command nointerlineskip.
. But quite to the contrary, LaTeX then issues an empty line adding vertical space and forcing the use of the long form of the above and below display skips.
– user4686
May 19 '14 at 11:39
1
@Mico why do not the reasons disqualifying$$
also disqualifybegin{equation}
? why isn't[
coherent in vertical spacing withbegin{equation}
?
– user4686
May 19 '14 at 11:52
1
@Mico your example with the extra vertical space above a$$
encountered in vertical mode is not convincing becausenointerlineskip$$
fixes the issue. But[
does a bit more thannointerlineskip
it creates a horzontal box of width.6linewidth
and this can NOT be undone!
– user4686
May 19 '14 at 19:47
Your link seems to be broken.
– celtschk
Jan 9 '12 at 20:07
Your link seems to be broken.
– celtschk
Jan 9 '12 at 20:07
@celtschk: Thanks for pointing out the problem; I've fixed the link.
– Mico
Jan 9 '12 at 20:12
@celtschk: Thanks for pointing out the problem; I've fixed the link.
– Mico
Jan 9 '12 at 20:12
@Mico you said
If that's the case, it avoids inserting any additional vertical space by issuing the command nointerlineskip.
. But quite to the contrary, LaTeX then issues an empty line adding vertical space and forcing the use of the long form of the above and below display skips.– user4686
May 19 '14 at 11:39
@Mico you said
If that's the case, it avoids inserting any additional vertical space by issuing the command nointerlineskip.
. But quite to the contrary, LaTeX then issues an empty line adding vertical space and forcing the use of the long form of the above and below display skips.– user4686
May 19 '14 at 11:39
1
1
@Mico why do not the reasons disqualifying
$$
also disqualify begin{equation}
? why isn't [
coherent in vertical spacing with begin{equation}
?– user4686
May 19 '14 at 11:52
@Mico why do not the reasons disqualifying
$$
also disqualify begin{equation}
? why isn't [
coherent in vertical spacing with begin{equation}
?– user4686
May 19 '14 at 11:52
1
1
@Mico your example with the extra vertical space above a
$$
encountered in vertical mode is not convincing because nointerlineskip$$
fixes the issue. But [
does a bit more than nointerlineskip
it creates a horzontal box of width .6linewidth
and this can NOT be undone!– user4686
May 19 '14 at 19:47
@Mico your example with the extra vertical space above a
$$
encountered in vertical mode is not convincing because nointerlineskip$$
fixes the issue. But [
does a bit more than nointerlineskip
it creates a horzontal box of width .6linewidth
and this can NOT be undone!– user4686
May 19 '14 at 19:47
|
show 4 more comments
$$
is not supported in LaTeX at all, it is primitive TeX syntax that just happens to sort of almost work most of the time. The standard LaTeX classes for example all have a fleqn
option to align rather than center [ ]
. Even with no options, the behaviour of [
and $$
are different at the start of a paragraph, where [
does
nointerlineskip
makebox[.6linewidth]{}%
before doing $$
thanks for editing, was just looking up the quote syntax, and by the time I came back you'd fixed it:-)
– David Carlisle
Jan 9 '12 at 10:21
2
Welcome back to TeX.SX!
– egreg
Jan 9 '12 at 15:10
add a comment |
$$
is not supported in LaTeX at all, it is primitive TeX syntax that just happens to sort of almost work most of the time. The standard LaTeX classes for example all have a fleqn
option to align rather than center [ ]
. Even with no options, the behaviour of [
and $$
are different at the start of a paragraph, where [
does
nointerlineskip
makebox[.6linewidth]{}%
before doing $$
thanks for editing, was just looking up the quote syntax, and by the time I came back you'd fixed it:-)
– David Carlisle
Jan 9 '12 at 10:21
2
Welcome back to TeX.SX!
– egreg
Jan 9 '12 at 15:10
add a comment |
$$
is not supported in LaTeX at all, it is primitive TeX syntax that just happens to sort of almost work most of the time. The standard LaTeX classes for example all have a fleqn
option to align rather than center [ ]
. Even with no options, the behaviour of [
and $$
are different at the start of a paragraph, where [
does
nointerlineskip
makebox[.6linewidth]{}%
before doing $$
$$
is not supported in LaTeX at all, it is primitive TeX syntax that just happens to sort of almost work most of the time. The standard LaTeX classes for example all have a fleqn
option to align rather than center [ ]
. Even with no options, the behaviour of [
and $$
are different at the start of a paragraph, where [
does
nointerlineskip
makebox[.6linewidth]{}%
before doing $$
edited Jan 9 '12 at 10:10
egreg
732k8919303253
732k8919303253
answered Jan 9 '12 at 9:43
David CarlisleDavid Carlisle
498k4111441892
498k4111441892
thanks for editing, was just looking up the quote syntax, and by the time I came back you'd fixed it:-)
– David Carlisle
Jan 9 '12 at 10:21
2
Welcome back to TeX.SX!
– egreg
Jan 9 '12 at 15:10
add a comment |
thanks for editing, was just looking up the quote syntax, and by the time I came back you'd fixed it:-)
– David Carlisle
Jan 9 '12 at 10:21
2
Welcome back to TeX.SX!
– egreg
Jan 9 '12 at 15:10
thanks for editing, was just looking up the quote syntax, and by the time I came back you'd fixed it:-)
– David Carlisle
Jan 9 '12 at 10:21
thanks for editing, was just looking up the quote syntax, and by the time I came back you'd fixed it:-)
– David Carlisle
Jan 9 '12 at 10:21
2
2
Welcome back to TeX.SX!
– egreg
Jan 9 '12 at 15:10
Welcome back to TeX.SX!
– egreg
Jan 9 '12 at 15:10
add a comment |
The differences have been described, in earlier answers, I am just adding here for illustrative purposes regarding vertical spaces this image:
which is obtained from this code:
documentclass{article}
begin{document}
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
end{document}
Notice the vertical spaces added by the [..]
construct, which furthermore are asymmetrical between before and after. Apart from that the [..]
does some error checking whose usefulness, IMHO, is limited to the real beginners in LaTeX
.
Here is another image:
obtained from this code:
documentclass{article}
begin{document}
noindent
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
end{document}
Notice the incoherent vertical spacing resulting from the use of [..]
.
I do not include the images here, but one can check that these incoherencies do disappear with usepackage{amsmath}
(for reasons which are clear from looking at the code reproduced in Mico's answer). I know my opinion is ultra-minoritarian, but clearly, only for people using amsmath
can one convincingly argue it is better to not use $$
directly.
Certainly $$
is not in the spirit of the LaTeX
syntax, but the [
in LaTeX2e
is not coherent with the other math environment in its handling of vertical spacing. Thus, I personnally concluded that when I am not loading amsmath
, I should rather avoid [
.
1
can I offer a bounty to the first upvoter?
– user4686
May 19 '14 at 12:36
1
OK, I've upvoted your answer. :-)
– Mico
May 19 '14 at 13:00
I think neither your examples invalidates the claim that[
-- unlike$$
-- takes care to avoid inserting an extra blank line if it's encountered while TeX is in vertical mode. In your first example, note that TeX is not in vertical mode at the end ofhrule
, hence there's no issue with$$
inadvisedly slipping in an extra blank line. Replace thehrule
andhrulefill
directives with a bunch of em-dashes, and it becomes quite apparent that the equation is nicely centered (between the rows of em-dashes) if it's typeset with[ ... ]
but not if it's typeset via$$...$$
.
– Mico
May 19 '14 at 13:15
@Mico are you sure? try replacinghrule
withhruleifvmode typeout{VMODE}else typeout{NOT VMODE}fi
and check the log. Andhrulefill
is followed bypar
. It is true that after]
or$$
,TeX
is in horizontal mode but this is another issue. I will check what you mean with the em-dashes.
– user4686
May 19 '14 at 13:55
@Mico I have replaced in my code samplehrule
by 15 successivetextemdash
es and then, as expected, because we start in horizontal mode, both[..]
and$$..$$
give the exact same result. (by the way I have upvoted your comment about upvoting my answer;-)
)
– user4686
May 19 '14 at 14:00
|
show 3 more comments
The differences have been described, in earlier answers, I am just adding here for illustrative purposes regarding vertical spaces this image:
which is obtained from this code:
documentclass{article}
begin{document}
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
end{document}
Notice the vertical spaces added by the [..]
construct, which furthermore are asymmetrical between before and after. Apart from that the [..]
does some error checking whose usefulness, IMHO, is limited to the real beginners in LaTeX
.
Here is another image:
obtained from this code:
documentclass{article}
begin{document}
noindent
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
end{document}
Notice the incoherent vertical spacing resulting from the use of [..]
.
I do not include the images here, but one can check that these incoherencies do disappear with usepackage{amsmath}
(for reasons which are clear from looking at the code reproduced in Mico's answer). I know my opinion is ultra-minoritarian, but clearly, only for people using amsmath
can one convincingly argue it is better to not use $$
directly.
Certainly $$
is not in the spirit of the LaTeX
syntax, but the [
in LaTeX2e
is not coherent with the other math environment in its handling of vertical spacing. Thus, I personnally concluded that when I am not loading amsmath
, I should rather avoid [
.
1
can I offer a bounty to the first upvoter?
– user4686
May 19 '14 at 12:36
1
OK, I've upvoted your answer. :-)
– Mico
May 19 '14 at 13:00
I think neither your examples invalidates the claim that[
-- unlike$$
-- takes care to avoid inserting an extra blank line if it's encountered while TeX is in vertical mode. In your first example, note that TeX is not in vertical mode at the end ofhrule
, hence there's no issue with$$
inadvisedly slipping in an extra blank line. Replace thehrule
andhrulefill
directives with a bunch of em-dashes, and it becomes quite apparent that the equation is nicely centered (between the rows of em-dashes) if it's typeset with[ ... ]
but not if it's typeset via$$...$$
.
– Mico
May 19 '14 at 13:15
@Mico are you sure? try replacinghrule
withhruleifvmode typeout{VMODE}else typeout{NOT VMODE}fi
and check the log. Andhrulefill
is followed bypar
. It is true that after]
or$$
,TeX
is in horizontal mode but this is another issue. I will check what you mean with the em-dashes.
– user4686
May 19 '14 at 13:55
@Mico I have replaced in my code samplehrule
by 15 successivetextemdash
es and then, as expected, because we start in horizontal mode, both[..]
and$$..$$
give the exact same result. (by the way I have upvoted your comment about upvoting my answer;-)
)
– user4686
May 19 '14 at 14:00
|
show 3 more comments
The differences have been described, in earlier answers, I am just adding here for illustrative purposes regarding vertical spaces this image:
which is obtained from this code:
documentclass{article}
begin{document}
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
end{document}
Notice the vertical spaces added by the [..]
construct, which furthermore are asymmetrical between before and after. Apart from that the [..]
does some error checking whose usefulness, IMHO, is limited to the real beginners in LaTeX
.
Here is another image:
obtained from this code:
documentclass{article}
begin{document}
noindent
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
end{document}
Notice the incoherent vertical spacing resulting from the use of [..]
.
I do not include the images here, but one can check that these incoherencies do disappear with usepackage{amsmath}
(for reasons which are clear from looking at the code reproduced in Mico's answer). I know my opinion is ultra-minoritarian, but clearly, only for people using amsmath
can one convincingly argue it is better to not use $$
directly.
Certainly $$
is not in the spirit of the LaTeX
syntax, but the [
in LaTeX2e
is not coherent with the other math environment in its handling of vertical spacing. Thus, I personnally concluded that when I am not loading amsmath
, I should rather avoid [
.
The differences have been described, in earlier answers, I am just adding here for illustrative purposes regarding vertical spaces this image:
which is obtained from this code:
documentclass{article}
begin{document}
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
[ E=mc^2]
hrule
$$E=mc^2$$
hrule
end{document}
Notice the vertical spaces added by the [..]
construct, which furthermore are asymmetrical between before and after. Apart from that the [..]
does some error checking whose usefulness, IMHO, is limited to the real beginners in LaTeX
.
Here is another image:
obtained from this code:
documentclass{article}
begin{document}
noindent
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
[ E=mc^2]
abchrulefillpar
$$E=mc^2$$
abchrulefillpar
end{document}
Notice the incoherent vertical spacing resulting from the use of [..]
.
I do not include the images here, but one can check that these incoherencies do disappear with usepackage{amsmath}
(for reasons which are clear from looking at the code reproduced in Mico's answer). I know my opinion is ultra-minoritarian, but clearly, only for people using amsmath
can one convincingly argue it is better to not use $$
directly.
Certainly $$
is not in the spirit of the LaTeX
syntax, but the [
in LaTeX2e
is not coherent with the other math environment in its handling of vertical spacing. Thus, I personnally concluded that when I am not loading amsmath
, I should rather avoid [
.
edited Apr 13 '17 at 12:35
Community♦
1
1
answered May 19 '14 at 11:46
user4686
1
can I offer a bounty to the first upvoter?
– user4686
May 19 '14 at 12:36
1
OK, I've upvoted your answer. :-)
– Mico
May 19 '14 at 13:00
I think neither your examples invalidates the claim that[
-- unlike$$
-- takes care to avoid inserting an extra blank line if it's encountered while TeX is in vertical mode. In your first example, note that TeX is not in vertical mode at the end ofhrule
, hence there's no issue with$$
inadvisedly slipping in an extra blank line. Replace thehrule
andhrulefill
directives with a bunch of em-dashes, and it becomes quite apparent that the equation is nicely centered (between the rows of em-dashes) if it's typeset with[ ... ]
but not if it's typeset via$$...$$
.
– Mico
May 19 '14 at 13:15
@Mico are you sure? try replacinghrule
withhruleifvmode typeout{VMODE}else typeout{NOT VMODE}fi
and check the log. Andhrulefill
is followed bypar
. It is true that after]
or$$
,TeX
is in horizontal mode but this is another issue. I will check what you mean with the em-dashes.
– user4686
May 19 '14 at 13:55
@Mico I have replaced in my code samplehrule
by 15 successivetextemdash
es and then, as expected, because we start in horizontal mode, both[..]
and$$..$$
give the exact same result. (by the way I have upvoted your comment about upvoting my answer;-)
)
– user4686
May 19 '14 at 14:00
|
show 3 more comments
1
can I offer a bounty to the first upvoter?
– user4686
May 19 '14 at 12:36
1
OK, I've upvoted your answer. :-)
– Mico
May 19 '14 at 13:00
I think neither your examples invalidates the claim that[
-- unlike$$
-- takes care to avoid inserting an extra blank line if it's encountered while TeX is in vertical mode. In your first example, note that TeX is not in vertical mode at the end ofhrule
, hence there's no issue with$$
inadvisedly slipping in an extra blank line. Replace thehrule
andhrulefill
directives with a bunch of em-dashes, and it becomes quite apparent that the equation is nicely centered (between the rows of em-dashes) if it's typeset with[ ... ]
but not if it's typeset via$$...$$
.
– Mico
May 19 '14 at 13:15
@Mico are you sure? try replacinghrule
withhruleifvmode typeout{VMODE}else typeout{NOT VMODE}fi
and check the log. Andhrulefill
is followed bypar
. It is true that after]
or$$
,TeX
is in horizontal mode but this is another issue. I will check what you mean with the em-dashes.
– user4686
May 19 '14 at 13:55
@Mico I have replaced in my code samplehrule
by 15 successivetextemdash
es and then, as expected, because we start in horizontal mode, both[..]
and$$..$$
give the exact same result. (by the way I have upvoted your comment about upvoting my answer;-)
)
– user4686
May 19 '14 at 14:00
1
1
can I offer a bounty to the first upvoter?
– user4686
May 19 '14 at 12:36
can I offer a bounty to the first upvoter?
– user4686
May 19 '14 at 12:36
1
1
OK, I've upvoted your answer. :-)
– Mico
May 19 '14 at 13:00
OK, I've upvoted your answer. :-)
– Mico
May 19 '14 at 13:00
I think neither your examples invalidates the claim that
[
-- unlike $$
-- takes care to avoid inserting an extra blank line if it's encountered while TeX is in vertical mode. In your first example, note that TeX is not in vertical mode at the end of hrule
, hence there's no issue with $$
inadvisedly slipping in an extra blank line. Replace the hrule
and hrulefill
directives with a bunch of em-dashes, and it becomes quite apparent that the equation is nicely centered (between the rows of em-dashes) if it's typeset with [ ... ]
but not if it's typeset via $$...$$
.– Mico
May 19 '14 at 13:15
I think neither your examples invalidates the claim that
[
-- unlike $$
-- takes care to avoid inserting an extra blank line if it's encountered while TeX is in vertical mode. In your first example, note that TeX is not in vertical mode at the end of hrule
, hence there's no issue with $$
inadvisedly slipping in an extra blank line. Replace the hrule
and hrulefill
directives with a bunch of em-dashes, and it becomes quite apparent that the equation is nicely centered (between the rows of em-dashes) if it's typeset with [ ... ]
but not if it's typeset via $$...$$
.– Mico
May 19 '14 at 13:15
@Mico are you sure? try replacing
hrule
with hruleifvmode typeout{VMODE}else typeout{NOT VMODE}fi
and check the log. And hrulefill
is followed by par
. It is true that after ]
or $$
, TeX
is in horizontal mode but this is another issue. I will check what you mean with the em-dashes.– user4686
May 19 '14 at 13:55
@Mico are you sure? try replacing
hrule
with hruleifvmode typeout{VMODE}else typeout{NOT VMODE}fi
and check the log. And hrulefill
is followed by par
. It is true that after ]
or $$
, TeX
is in horizontal mode but this is another issue. I will check what you mean with the em-dashes.– user4686
May 19 '14 at 13:55
@Mico I have replaced in my code sample
hrule
by 15 successive textemdash
es and then, as expected, because we start in horizontal mode, both [..]
and $$..$$
give the exact same result. (by the way I have upvoted your comment about upvoting my answer ;-)
)– user4686
May 19 '14 at 14:00
@Mico I have replaced in my code sample
hrule
by 15 successive textemdash
es and then, as expected, because we start in horizontal mode, both [..]
and $$..$$
give the exact same result. (by the way I have upvoted your comment about upvoting my answer ;-)
)– user4686
May 19 '14 at 14:00
|
show 3 more comments
Also align
does not behave the same way as [...]
regards to spacing before. [...]
and the equation
environment can adjust the spacing above the equation if there is enough
room, align
cannot (because of the manner in which it is constructed)
1
An example of this spacing difference can be found at align vs equation.
– Peter Grill
Jan 9 '12 at 20:20
And what is the difference between[...]
and(...)
.
– jafan
Nov 15 '13 at 18:13
1
The first is displayed math the other is a slight alternative to $... $
– daleif
Nov 15 '13 at 22:53
add a comment |
Also align
does not behave the same way as [...]
regards to spacing before. [...]
and the equation
environment can adjust the spacing above the equation if there is enough
room, align
cannot (because of the manner in which it is constructed)
1
An example of this spacing difference can be found at align vs equation.
– Peter Grill
Jan 9 '12 at 20:20
And what is the difference between[...]
and(...)
.
– jafan
Nov 15 '13 at 18:13
1
The first is displayed math the other is a slight alternative to $... $
– daleif
Nov 15 '13 at 22:53
add a comment |
Also align
does not behave the same way as [...]
regards to spacing before. [...]
and the equation
environment can adjust the spacing above the equation if there is enough
room, align
cannot (because of the manner in which it is constructed)
Also align
does not behave the same way as [...]
regards to spacing before. [...]
and the equation
environment can adjust the spacing above the equation if there is enough
room, align
cannot (because of the manner in which it is constructed)
answered Jan 9 '12 at 10:22
daleifdaleif
33.6k255118
33.6k255118
1
An example of this spacing difference can be found at align vs equation.
– Peter Grill
Jan 9 '12 at 20:20
And what is the difference between[...]
and(...)
.
– jafan
Nov 15 '13 at 18:13
1
The first is displayed math the other is a slight alternative to $... $
– daleif
Nov 15 '13 at 22:53
add a comment |
1
An example of this spacing difference can be found at align vs equation.
– Peter Grill
Jan 9 '12 at 20:20
And what is the difference between[...]
and(...)
.
– jafan
Nov 15 '13 at 18:13
1
The first is displayed math the other is a slight alternative to $... $
– daleif
Nov 15 '13 at 22:53
1
1
An example of this spacing difference can be found at align vs equation.
– Peter Grill
Jan 9 '12 at 20:20
An example of this spacing difference can be found at align vs equation.
– Peter Grill
Jan 9 '12 at 20:20
And what is the difference between
[...]
and (...)
.– jafan
Nov 15 '13 at 18:13
And what is the difference between
[...]
and (...)
.– jafan
Nov 15 '13 at 18:13
1
1
The first is displayed math the other is a slight alternative to $... $
– daleif
Nov 15 '13 at 22:53
The first is displayed math the other is a slight alternative to $... $
– daleif
Nov 15 '13 at 22:53
add a comment |
An additional answer that is one of the most important for me: the cleveref
package will automatically handle an equation contained in begin{equation}
but not [
.
5
Equations using[...]
are not numbered, and so the concept ofref
has no meaning in this context.
– Steven B. Segletes
Jan 30 '17 at 14:24
Your posting appears to apply to all unnumbered environments, not justequation
-type environments. For thelabel
-ref
(orlabel
-cref
) mechanism to "work", the object (say, anequation
environment) that's beinglabel
-ed has to be associated with a counter variable that's being incremented (either by the environment itself or via a command such ascaption
). Since[ ...]
, by design, does not increment any counters, it's not possible to use theref
orcref
to create cross-references to the non-existent equation numbers.
– Mico
Jan 30 '17 at 15:41
add a comment |
An additional answer that is one of the most important for me: the cleveref
package will automatically handle an equation contained in begin{equation}
but not [
.
5
Equations using[...]
are not numbered, and so the concept ofref
has no meaning in this context.
– Steven B. Segletes
Jan 30 '17 at 14:24
Your posting appears to apply to all unnumbered environments, not justequation
-type environments. For thelabel
-ref
(orlabel
-cref
) mechanism to "work", the object (say, anequation
environment) that's beinglabel
-ed has to be associated with a counter variable that's being incremented (either by the environment itself or via a command such ascaption
). Since[ ...]
, by design, does not increment any counters, it's not possible to use theref
orcref
to create cross-references to the non-existent equation numbers.
– Mico
Jan 30 '17 at 15:41
add a comment |
An additional answer that is one of the most important for me: the cleveref
package will automatically handle an equation contained in begin{equation}
but not [
.
An additional answer that is one of the most important for me: the cleveref
package will automatically handle an equation contained in begin{equation}
but not [
.
edited Sep 4 '17 at 19:12
Mico
285k32388778
285k32388778
answered Jan 30 '17 at 14:21
barnhillecbarnhillec
22817
22817
5
Equations using[...]
are not numbered, and so the concept ofref
has no meaning in this context.
– Steven B. Segletes
Jan 30 '17 at 14:24
Your posting appears to apply to all unnumbered environments, not justequation
-type environments. For thelabel
-ref
(orlabel
-cref
) mechanism to "work", the object (say, anequation
environment) that's beinglabel
-ed has to be associated with a counter variable that's being incremented (either by the environment itself or via a command such ascaption
). Since[ ...]
, by design, does not increment any counters, it's not possible to use theref
orcref
to create cross-references to the non-existent equation numbers.
– Mico
Jan 30 '17 at 15:41
add a comment |
5
Equations using[...]
are not numbered, and so the concept ofref
has no meaning in this context.
– Steven B. Segletes
Jan 30 '17 at 14:24
Your posting appears to apply to all unnumbered environments, not justequation
-type environments. For thelabel
-ref
(orlabel
-cref
) mechanism to "work", the object (say, anequation
environment) that's beinglabel
-ed has to be associated with a counter variable that's being incremented (either by the environment itself or via a command such ascaption
). Since[ ...]
, by design, does not increment any counters, it's not possible to use theref
orcref
to create cross-references to the non-existent equation numbers.
– Mico
Jan 30 '17 at 15:41
5
5
Equations using
[...]
are not numbered, and so the concept of ref
has no meaning in this context.– Steven B. Segletes
Jan 30 '17 at 14:24
Equations using
[...]
are not numbered, and so the concept of ref
has no meaning in this context.– Steven B. Segletes
Jan 30 '17 at 14:24
Your posting appears to apply to all unnumbered environments, not just
equation
-type environments. For the label
-ref
(or label
-cref
) mechanism to "work", the object (say, an equation
environment) that's being label
-ed has to be associated with a counter variable that's being incremented (either by the environment itself or via a command such as caption
). Since [ ...]
, by design, does not increment any counters, it's not possible to use the ref
or cref
to create cross-references to the non-existent equation numbers.– Mico
Jan 30 '17 at 15:41
Your posting appears to apply to all unnumbered environments, not just
equation
-type environments. For the label
-ref
(or label
-cref
) mechanism to "work", the object (say, an equation
environment) that's being label
-ed has to be associated with a counter variable that's being incremented (either by the environment itself or via a command such as caption
). Since [ ...]
, by design, does not increment any counters, it's not possible to use the ref
or cref
to create cross-references to the non-existent equation numbers.– Mico
Jan 30 '17 at 15:41
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f40492%2fwhat-are-the-differences-between-align-equation-and-displaymath%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
14
For your first question, see tex.stackexchange.com/questions/503/why-is-preferable-to For the second: tex.stackexchange.com/questions/321/align-vs-equation
– Torbjørn T.
Jan 9 '12 at 6:53
amsmath
has a coherent redefinition of[
. But for some aspects of theLaTeX
[
, see my answer– user4686
May 19 '14 at 12:33
You should also be using
(...)
instead of$...$
too.– john w.
Jan 20 '15 at 18:49