5

The amsmath package changes the \dots command to have different vertical alignment depending on context (I'm not sure if it does anything else to it). The ellipsis package changes the \dots command to ensure correct spacing in certain textual contexts. However, it seems to undo the changes made by amsmath. Is there a way to make the features work simultaneously?

The following is an mwe:

\documentclass[a4paper]{book}

\usepackage{amsmath}
\usepackage{ellipsis}

\begin{document}

a \dots{} b

a\dots{}b
\[a + \dots + b\]

\end{document}

If the ellipsis package is used, the ellipsis in math is not vertically centered. If it is not used, there is an extra (thin?) space after the ellipsis in the text. The order of \usepackage's do not seem to matter.

ronno
  • 1,325
  • 2
    You shouldn't be using \dots{} in math mode anyway, because it confuses the macros of amsmath. – egreg Jul 09 '14 at 09:41
  • I can't see any difference in the vertical alignment of \dots with and without amsmath. – Ian Thompson Jul 09 '14 at 09:44
  • 3
    Inside of math you shouldn't use the {} after \dots, you must let them decide the spacing a + \dots + b. By the way, this may interest you: http://tex.stackexchange.com/q/168383/21930 and http://tex.stackexchange.com/q/179336/21930. – Manuel Jul 09 '14 at 09:55
  • @egreg -- huh? shouldn't use \dots in math? or were you just referring to the {} after \dots? the amsmath documentation specifically recommends using \dots unless a final reading shows that some of them have gotten misaligned. (the {} is almost always wrong though.) – barbara beeton Jul 09 '14 at 12:39
  • 1
    @barbarabeeton Sorry, I wasn't clear: {} shouldn't be used after \dots in math mode. – egreg Jul 09 '14 at 12:49
  • The {} after \dots in math mode was accidental when typing out the mwe. Since in this case it doesn't affect the output (at least noticably) and hence the question, I edited it out. – ronno Jul 09 '14 at 17:39
  • @ronno It does, in fact, affect quite much. a + \dots{} + b does not give you vertically shifted dots, which is what, at first time, you asked for. – Manuel Jul 09 '14 at 17:42
  • @Manuel Ah, you're right, of course. Then the edit was needed to make the mwe work consistently with the question. Thanks. – ronno Jul 09 '14 at 17:45

2 Answers2

7

The ellipsis package does

\AtBeginDocument{%
   \DeclareRobustCommand{\dots}{%
     \ifmmode\mathellipsis\else\expandafter\textellipsis\fi}%
}

which is wrong, because it reinstates the LaTeX kernel definition without taking into account that other package might have redefined it. The package author's aim is ensuring that in text mode the redefined \textellipsis is used. Alas, this breaks the amsmath mechanism.

Solution: reinstate the correct definition given by amsmath that has \textellipsis for text mode.

\documentclass[a4paper]{book}

\usepackage{letltxmacro} % for saving and reinstating the correct macro
\usepackage{amsmath}
% save the definition of \dots by amsmath
\LetLtxMacro{\amsmathdots}{\dots}

\usepackage{ellipsis}

% this must go after \usepackage{ellipsis}
\AtBeginDocument{\LetLtxMacro{\dots}{\amsmathdots}}

\begin{document}

a \dots{} b

a\dots{}b
\[a + \dots + b\]

\end{document}

enter image description here

egreg
  • 1,121,712
0

This is a solution I used some time ago. It adds \ellipsisbeforegap and \ellipsisaftergap just because I needed it. You can delete it.

\documentclass{scrartcl}

\usepackage{mathtools}
\usepackage{ellipsis}

\makeatletter
\renewcommand*{\mathellipsis}{%
    \mathinner{%
        \kern\ellipsisbeforegap%
        {\ldotp}\kern\ellipsisgap%
        {\ldotp}\kern\ellipsisgap%
        {\ldotp}\kern\ellipsisaftergap%
    }%
}
\renewcommand*{\dotsb@}{%
    \mathinner{%
        \kern\ellipsisbeforegap%
        {\cdotp}\kern\ellipsisgap%
        {\cdotp}\kern\ellipsisgap%
        {\cdotp}\kern\ellipsisaftergap%
    }%
}
\renewcommand*{\@cdots}{%
    \mathinner{%
        \kern\ellipsisbeforegap%
        {\cdotp}\kern\ellipsisgap%
        {\cdotp}\kern\ellipsisgap%
        {\cdotp}\kern\ellipsisaftergap%
    }%
}
\renewcommand*{\ellipsis@default}{%
    \ellipsis@before
    \kern\ellipsisbeforegap
    .\kern\ellipsisgap
    .\kern\ellipsisgap
    .\kern\ellipsisgap
    \ellipsis@after\relax}
\renewcommand*{\ellipsis@centered}{%
    \ellipsis@before
    \kern\ellipsisbeforegap
    .\kern\ellipsisgap
    .\kern\ellipsisgap
    .\kern\ellipsisaftergap
    \ellipsis@after\relax}
\AtBeginDocument{%
    \DeclareRobustCommand*{\dots}{%
        \ifmmode\@xp\mdots@\else\@xp\textellipsis\fi}}
\def\ellipsisgap{.1em}
\def\ellipsisbeforegap{.05em}
\def\ellipsisaftergap{.05em}
\makeatother

\begin{document}

a \dots\ b

a\dots b

\[ a + \dots + b \]

\end{document}

The relevant part to your question (although my code is more complete) is

\AtBeginDocument{%
    \DeclareRobustCommand*{\dots}{%
        \ifmmode\@xp\mdots@\else\@xp\textellipsis\fi}}

enter image description here

Manuel
  • 27,118