Initial commit

This commit is contained in:
Mateus Pinto Rodrigues
2017-11-11 15:15:10 -02:00
commit 58c3bd6728
1202 changed files with 434097 additions and 0 deletions

View File

@@ -0,0 +1,358 @@
\documentclass[a4paper]{article}
\usepackage{expl3}
\usepackage[overload]{empheq}
\usepackage{breqn}
\begin{document}
This is a test document for general fontification support of macros
and environments provided by \LaTeX{} and other packages within
AUC\TeX. As it is not part of \verb|ert|-tests, it does not have an
\verb|out|-counterpart.
\part{Macros}
\section{Special characters}
\subsection{Standard reserved characters}
\subsubsection{\protect\LaTeX{} input}
The following symbols are reserved characters that have a special
meaning under \LaTeX{}.
\begin{center}
\begin{tabular}{@{}*{8}{c}}
\hline
\verb|#| & \verb|$| & \verb|%| & \verb|^|
& \verb|&| & \verb|_| & \verb|{| & \verb|}| \\
\verb|~| & \verb|`| & \verb|'| & \verb|=|
& \verb|.| \\
\hline
\end{tabular}\\
\end{center}
In a document, characters in the first line are printed by using a
prefix \verb|\| (backslash). The characters in the second line become
control symbols taking an argument when prefixed with a backslash.
\subsubsection{AUC\protect\TeX{} fontification}
AUC\TeX{} has the following strategy for fontification:
\begin{description}
\item[Control symbols without argument] do not get any fontification
as they only print a special character and have a textual context,
e.g. \$10, 5\%, Mr.\&Mrs. They are listed below:
\begin{center}
\begin{tabular}{@{}*{4}{cl}@{}}
\hline
\# & \verb|\#| & \$ & \verb|\$|
& \% & \verb|\%| & \& & \verb|\&| \\
\_ & \verb|\_| & \{ & \verb|\{|
& \} & \verb|\}| \\
\hline
\end{tabular}
\end{center}
\item[Control symbols with argument] do not receive any fontification.
These macros take a mandatory argument, but they have a textual
context. Since the argument is usually not enclosed in braces,
fontification would be rather distracting:
\begin{center}
\begin{tabular}{@{}*{4}{cl}@{}}
\hline
\`o & \verb|\`o| & \'o & \verb|\'o|
& \^o & \verb|\^o| & \~o & \verb|\~o| \\
\=o & \verb|\=o| & \.o & \verb|\.o|
& \"o & \verb|\"o| \\
\hline
\end{tabular} \\[1ex]
\begin{minipage}{0.4\linewidth}\centering
H\^{o}tel, na\"\i ve, \'{e}l\`{e}ve,\\
sm\o rrebr\o d, !`Se\~{n}orita!
\end{minipage}\quad
\begin{minipage}{0.4\linewidth}\centering
H\^otel, na\"\i ve, \'el\`eve,\\
sm\o rrebr\o d, !`Se\~norita!
\end{minipage}
\end{center}
\item[Control words] receive fontification, e.g.
\begin{center}
\begin{tabular}{@{}*{4}{cl}@{}}
\hline
\u o & \verb|\u o| & \v o & \verb|\v o|
& \H o & \verb|\H o| & \c o & \verb|\c o| \\
\d o & \verb|\d o| & \b o & \verb|\b o|
& \t oo & \verb|\t oo| \\[6pt]
\oe & \verb|\oe| & \OE & \verb|\OE|
& \ae & \verb|\ae| & \AE & \verb|\AE| \\
\aa & \verb|\aa| & \AA & \verb|\AA|
& \c c & \verb|\c c| \\[6pt]
\o & \verb|\o| & \O & \verb|\O|
& \l & \verb|\l| & \L & \verb|\L| \\
\i & \verb|\i| & \j & \verb|\J|
& \ss & \verb|\ss| \\
\hline
\end{tabular}\\[1ex]
\end{center}
\end{description}
\subsection{@ character}
\subsubsection{\protect\LaTeX{} input}
In regular text, \verb|@| is not a special character and can be used
as `foo@bar'. Further, \verb|\@| can be used to force a wide space
after an uppercase character, e.g. PC\@.
On the other hand, \verb|@| is used as ``letter'' for defining internal
macros, e.g. \verb|\@gobble|.
\subsubsection{AUC\protect\TeX{} fontification}
Being a non-textual macro, \verb|\@| receives a fontification in
AUC\TeX. Used as letter as part of a macro, it gets the fontification
as the rest. Example \bgroup\ttfamily \string\@gobble\egroup.
\subsection{\_ and : characters}
\subsubsection{\protect\LaTeX{} input}
For \LaTeXe, the behavior of \verb|_| and \verb|\_| was described
above. \verb|:| is not special for regular text. \verb|\:| is a
spacing macro ($\frac{4}{18}$ quad) within math mode.
\LaTeX3 does not use \verb|@| as ``letter'' for defining internal
macros. Instead, the symbols \verb|_| and \verb|:| are used in
internal macro names to provide structure. These extra letters are
used only between parts of a macro name (no strange vowel
replacement)\cite{expl3}.
\subsubsection{AUC\protect\TeX{} fontification}
\verb|\:| is only allowed in math mode; fontification is done there,
e.g. $a\:\:+b$ or
\begin{equation}
\int_1^2 \ln x \mathrm{d}x
\qquad
\int_1^2 \ln x \:\:\:\mathrm{d}x
\end{equation}
Regarding \LaTeX3, \verb|expl3| says:
\begin{quote}
3.2.1 Separating private and public material \\
Functions created by a module may either be ``public'' (documented
with a defined interface) or ``private'' (to be used only within
that module, and thus not formally documented). It is important
that only documented interfaces are used; [...] \\
To allow clear separation of these two cases, the following
convention is used. Private functions should be defined with
\verb|__| added to the beginning of the module name. Thus
\begin{quote}
\ttfamily \catcode`\_11\relax
\string\module_foo:nnn
\end{quote}
is a public function which should be documented while
\begin{quote}
\ttfamily \catcode`\_11\relax
\string\__module_foo:nnn
\end{quote}
is private to the module, and should not be used outside of that
module.
\end{quote}
%
Hopefully, this means that \verb|\__module_foo:nnn| macros will not be
used somewhere in the preamble of a \verb|.tex| file -- they should
appear only in a \verb|.dtx| file.
AUC\TeX{} provides a style file \verb|expl3.el| containing this code:
\begin{verbatim}
(defvar LaTeX-expl3-syntax-table
(let ((st (copy-syntax-table LaTeX-mode-syntax-table)))
;; Make _ and : symbol chars
(modify-syntax-entry ?\_ "_" st)
(modify-syntax-entry ?\: "_" st)
st))
\end{verbatim}
It changes the syntax for \verb|_| and \verb|:| from
\textsl{punctuation} to \textsl{symbol}. For public functions
mentioned above, this results in correct fontification in regular
\verb|.tex| files. For private functions, \verb|font-latex.el|
provides some code for doc\TeX{} mode to fontify them correctly.
\section{Math mode}
\subsection{\protect\LaTeX{} input}
In-line math is typeset with plain \TeX{}
\verb|$|\,\textsl{formula\_text}\,\verb|$| or \LaTeX{} shorthand
\verb|\(|\,\textsl{formula\_text}\,\verb|\)|, e.g. $(a+b)^2$ is equal
to \(a^2+2ab+b^2\).
\subsection{AUC\protect\TeX{} fontification}
AUC\TeX{} fontifies math with \texttt{font-latex-math-face}. There is
a bug report \#26630 for this issue: {\bfseries Text before, $(a+b)^2$
is equal to \(a^2+2ab+b^2\)!} First math expression is fontified
with
\begin{quote}
\verb|(font-latex-math-face font-latex-bold-face)|
\end{quote}
while the second with
\begin{quote}
\verb|(font-latex-bold-face font-latex-math-face)|
\end{quote}
\part{Environments}
\section{Math mode}
\subsection{\protect\LaTeX{} input}
Standard \LaTeX{} math environments are \verb|equation|,
\verb|displaymath| and others. \verb|amsmath| package provides
environments like \verb|align|, \verb|flalign| etc. These
environments do not take any arguments. Environments like
\verb|alignat|, \verb|xalignat| and \verb|xxalignat| take a mandatory
argument. Other math environments provided by packages like
\verb|empheq.sty| or \verb|breqn.sty| take an optional and/or
mandatory argument.
\subsection{AUC\protect\TeX{} fontification}
AUC\TeX{} fontifies the entire math content with
\texttt{font-latex-math-face}. The optional and mandatory argument(s)
should not be fontified. Spaces or line breaks are used in order to
distinguish argument from math content, i.e.
\begin{quote}
\verb|\begin{<mathenv>}[<opt-arg>]{<mand-arg>}|
\end{quote}
will be fontified differently than
\begin{quote}
\verb|\begin{<mathenv>}[<opt-arg>] {<math-content>}|
\end{quote}
or
\begin{quote}
\verb|\begin{<mathenv>} [<math-content>]{<math-content>}|
\end{quote}
The relevant functions is \verb|font-latex.el| are
\begin{quote}
\verb|font-latex-match-math-envII|\quad and \\
\verb|font-latex-extend-region-backwards-math-envII|
\end{quote}
\subsubsection{Standard \protect\LaTeX{}}
Examples taken from \cite{voss16}.
\begin{equation}
f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
\end{equation}
or
\begin{displaymath}
f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
\end{displaymath}
or
\[ f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right) \]
or
\begin{eqnarray*}
y & = & d\\
y & = & cx+d\\
y & = & bx^{2}+cx+d\\
y & = & ax^{3}+bx^{2}+cx+d
\end{eqnarray*}
\subsubsection{\texttt{amsmath} package}
Examples taken from \cite{voss16}.
\begin{align}
y &= d & z &= 1 \\
y &= cx+d & z &= x+1 \\
y_{12} &= bx^{2}+cx+d & z &= x^{2}+x+1\nonumber \\
y(x) &= ax^{3}+bx^{2}+cx+d & z &= x^{3}+x^{2}+x+1
\end{align}
or
\begin{alignat}{2}
y &= d & z &= 1 \\
y &= cx+d & z & =x+1 \\
y_{12} &= bx^{2}+cx+d & z &= x^{2}+x+1\nonumber \\
y(x) &= ax^{3}+bx^{2}+cx+d & z &= x^{3}+x^{2}+x+1
\end{alignat}
\subsubsection{\texttt{breqn} package}
Examples taken from \cite{breqn}:
\begin{dmath}
f(x)=\frac{1}{x} \condition{for $x\neq 0$}
\end{dmath}
or
\begin{dmath}[label={sna74}]
\frac{1}{6} \left(\sigma(k,h,0) +\frac{3(h-1)}{h}\right)
+\frac{1}{6} \left(\sigma(h,k,0) +\frac{3(k-1)}{k}\right)
=\frac{1}{6} \left(\frac{h}{k} +\frac{k}{h} +\frac{1}{hk}\right)
+\frac{1}{2} -\frac{1}{2h} -\frac{1}{2k},
\end{dmath}
or \newcommand\mx[1]{\begin{math}#1\end{math}}%
\begin{dseries}[frame]
\mx{v^{[2]} =(0,5,5,0,9,5,1,0)},
\mx{v^{[3]} =(0,9,11,9,10,12,0,1)}.
\end{dseries}
\begin{dgroup*}
\begin{dmath*}
H_1^3 = x_1 + x_2 + x_3
\end{dmath*},
\begin{dmath*}
H_2^2 = x_1^2 + x_1 x_2 + x_2^2 - q_1 - q_2
\end{dmath*},
\begin{dsuspend}
and
\end{dsuspend}
\begin{dmath*}
H_3^1 = x_1^3 - 2x_1 q_1 - x_2 q_1
\end{dmath*}.
\end{dgroup*}
\subsubsection{\texttt{empheq} package}
Examples taken from \cite{empheq}:
\begin{empheq}{align*}
a&= b \tag{*}\\
E&= mc^2 + \int_a^a x\,dx
\end{empheq}
or
\begin{empheq}{alignat=2}
a &= b &\quad c &= d \\
\text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
\end{empheq}
or
\begin{empheq}[innerbox=\fbox,
left=L\Rightarrow]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
or
\begin{empheq}[
left={\parbox[c][\EmphEqdisplayheight+\EmphEqdisplaydepth][t]
{4.5cm}
{You may find this kind of description useful.}\enspace}%
]{align}
a&=\int_0^1 x\,dx +\frac{foo + bar}{baz}\\
E&= mc^2
\end{empheq}
\begin{thebibliography}{9}\raggedright
\bibitem{breqn} Downes, Michael J.; H\o gholm, Morten: The
\texttt{breqn} package. Released 2017/01/27.
\bibitem{empheq} H\o gholm, Morten; Madsen, Lars: The \texttt{empheq}
package. Released 2014/08/04.
\bibitem{expl3} The \LaTeX3 Project: The expl3 package and \LaTeX3
programming. Released 2017/04/01.
\bibitem{voss16} Vo\ss, Herbert: Mathematical Typesetting with
\LaTeX. TUG-Version 0.32, released 2016/11/08.
\end{thebibliography}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

View File

@@ -0,0 +1,143 @@
\documentclass[a4paper]{article}
\usepackage{minted}
\usepackage{listings}
\usepackage{fancyvrb}
\begin{document}
This is a test document for fontification support of verbatim
\emph{macros} provided by \LaTeX{} and other packages within AUC\TeX.
As it is not part of \verb|ert|-tests, it does not have an
\verb|out|-counterpart. Parsing should be enabled when loading this
file, namely \verb|(setq TeX-parse-self t)| in \verb|.emacs|.
\section{The problem}
The \verb|verb| macro provided by vanilla \LaTeX{} does not receive
any special fontification within AUC\TeX. It is fontified with
\verb|font-latex-sedate-face|. Other \verb|verb| macros provided by
packages like \verb|listings|, \verb|minted| or \verb|fancyvrb| are
fontified with \verb|font-lock-keyword-face| as they are added to
\verb|textual| keyword class within \verb|font-latex.el|.
Next issue is that \verb|verb| macros from modern packages take an
optional argument or even a mandatory argument before the
\verb|verbatim| content. This issue was not addressed in
\verb|font-latex.el|.
\section{The solution}
\subsection{Vanilla \LaTeX}
The issue with fontification of \verb|verb| macro is solved in
\verb|font-latex.el| by adding \verb|("verb" "*")| to
\verb|`font-latex-built-in-keyword-classes'|. This construct
fontifies only the macro itself---the argument is left out for
syntactic fontification.
\subsection{Optional argument}
This issue can be fixed in \verb|font-latex.el| by extending the
regexp for \verb|verb| macros with delimiters/braces in
\verb|`font-latex-set-syntactic-keywords'| with:
\begin{quote}
\verb|"\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"|
\end{quote}
The same line is used for matching optional arguments in verbatim
environments.
\section{The result}
\subsection{Vanilla \LaTeX}
Some text \verb|verb input|, % comment
$a+b$ and \verb*"verb input" % comment
\subsection{listings package}
Some text \lstinline|verb input with delims|, % comment
$a+b$ \lstinline[showspaces,basicstyle=\ttfamily]/verb input with delims/, % comment
%
\lstinline[%
basicstyle=\sffamily]!multiline in opt. arg!, % comment
%
\lstinline[%
basicstyle=\sffamily
]-multiline in opt. arg- % comment
Some text \lstinline{verb input with braces}, % comment
$a+b$ \lstinline[showspaces]{verb input with braces}, % comment
%
\lstinline[%
basicstyle=\sffamily]{multiline in opt. arg}, % comment
%
\lstinline[
basicstyle=\sffamily
]{multiline in opt. arg} % comment
\subsection{minted package}
Some text \mint{text}|verb input| % comment
$a+b$ \mint[showspaces]{text}/verb input/ % comment
Some text \mint[
showspaces
]{text}!verb input! % comment
Some text \mint[showspaces]{%
text%
}+verb input+ % comment
\newmint{text}{showspaces} %
\text|verb input| and \text[showspaces=false]|verb input| % comment
\newmint[mytext]{text}{showspaces} %
\mytext|verb input| and \mytext[%
showspaces=false
]|verb input| % comment
Some text \mintinline{text}|verb input| % comment
$a+b$ \mintinline[showspaces]{text}|verb input| % comment
Some text \mintinline[
showspaces
]{text}|verb input| % comment
Some text \mintinline[showspaces]{%
text%
}|verb input| % comment
\newmintinline{text}{showspaces} %
\textinline|verb input with delims| and \textinline[%
showspaces=false
]|verb input with delims| % comment
\textinline{verb input with braces} and \textinline[%
showspaces=false
]{verb input with braces} % comment
\newmintinline[mytextinline]{text}{showspaces} %
\mytextinline|verb input with delims| and \mytextinline[%
showspaces=false
]|verb input with delims|
\mytextinline{verb input with braces} and \mytextinline[%
showspaces=false
]{verb input with braces}
\subsection{fancyvrb package}
Some text \Verb|verb input| and % comment
\Verb[showspaces]|verb input| and \Verb[
showspaces
]|verb input|
Some text \Verb!verb input! and % comment
\Verb[showspaces]"verb input" and \Verb[
showspaces
]#verb input#
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-command-extra-options: "-shell-escape"
%%% End:

View File

@@ -0,0 +1,28 @@
Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod \(0 = 1\) tempor incidunt ut $a^{2} + b^{2} = c^{2}$ labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur.
\begin{tabular}{| l | l | l | l |}
Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci
\end{tabular}
% Test for unambiguousness of macros starting a paragraph. E.g.
% caption vs. captionsetup
Lorem ipsum dolor sit amet, consectetur adipisci,
lorem ipsum dolor
\captionsetup{key=val}
sit amet, consectetur adipisci
Lorem ipsum dolor sit amet, consectetur adipisci,
lorem ipsum dolor
\caption{key=val}
sit amet, consectetur adipisci
% par vs. parencite
Lorem ipsum dolor sit amet, consectetur adipisci,
lorem ipsum dolor
\parencite{key}
sit amet, consectetur adipisci
Lorem ipsum dolor sit amet, consectetur adipisci,
lorem ipsum dolor
\par
sit amet, consectetur adipisci

View File

@@ -0,0 +1,26 @@
Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod
\(0 = 1\) tempor incidunt ut $a^{2} + b^{2} = c^{2}$ labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrum exercitationem
ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi
consequatur.
\begin{tabular}{| l | l | l | l |}
Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci
\end{tabular}
% Test for unambiguousness of macros starting a paragraph. E.g.
% caption vs. captionsetup
Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
\captionsetup{key=val} sit amet, consectetur adipisci
Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
\caption{key=val}
sit amet, consectetur adipisci
% par vs. parencite
Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
\parencite{key} sit amet, consectetur adipisci
Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
\par
sit amet, consectetur adipisci

View File

@@ -0,0 +1,168 @@
;;; latex-test.el --- tests for LaTeX mode
;; Copyright (C) 2014--2017 Free Software Foundation, Inc.
;; This file is part of AUCTeX.
;; AUCTeX is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; AUCTeX is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with AUCTeX; see the file COPYING. If not, write to the Free
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301, USA.
;;; Code:
(require 'ert)
(require 'latex)
;; Add the "style/" directory to `TeX-style-path',
;; so we can load style files inside tests.
(add-to-list 'TeX-style-path
(expand-file-name "../../style"
(when load-file-name
(file-name-directory load-file-name))))
(defun AUCTeX-set-ert-path (&rest sym-val)
"Set first element of SYM-VAL to the next one, and so on.
The value is the path to the test file, make sure it is expanded
in the right directory even when the ERT test from the command
line and from another directory."
(while sym-val
(set (pop sym-val)
(expand-file-name (pop sym-val)
(when load-file-name
(file-name-directory load-file-name))))))
(AUCTeX-set-ert-path
'LaTeX-indent-tabular-test/in
"tabular-in.tex"
'LaTeX-indent-tabular-test/out
"tabular-out.tex"
'LaTeX-filling/in
"latex-filling-in.tex"
'LaTeX-filling/out
"latex-filling-out.tex"
'LaTeX-math-indent/in
"math-indent-in.tex"
'LaTeX-math-indent/out
"math-indent-out.tex"
'tabular-count-ampersands/in
"tabular-count-ampersands-in.tex"
'tabular-count-ampersands/out
"tabular-count-ampersands-out.tex")
;; Test for detecting \& in a table cell added; see
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010
;; Test for missing & in row added; see
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
(ert-deftest LaTeX-indent-tabular ()
(should (string=
(with-temp-buffer
(insert-file-contents LaTeX-indent-tabular-test/in)
(LaTeX-mode)
(indent-region (point-min) (point-max))
(buffer-string))
(with-temp-buffer
(insert-file-contents LaTeX-indent-tabular-test/out)
(buffer-string)))))
;; Another test for indentation, but for math mode, see
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20227 Let's keep those tests
;; separated so it would be easier to find the culprit of a future failure.
(ert-deftest LaTeX-math-indent ()
(should (string=
(with-temp-buffer
(insert-file-contents LaTeX-math-indent/in)
(LaTeX-mode)
(indent-region (point-min) (point-max))
(buffer-string))
(with-temp-buffer
(insert-file-contents LaTeX-math-indent/out)
(buffer-string)))))
;; Test LaTeX code with math modes is indented as expected. This has mostly to
;; do with the value of `LaTeX-fill-break-at-separators' and how
;; `LaTeX-fill-move-to-break-point' handles it. If the test fails, try to look
;; there. The second part of the test looks for unambiguousness of
;; macros starting a paragraph
;; (http://lists.gnu.org/archive/html/auctex/2017-03/msg00009.html)
(ert-deftest LaTeX-filling ()
(should (string=
(with-temp-buffer
(insert-file-contents LaTeX-filling/in)
(LaTeX-mode)
(let ((fill-column 70))
(fill-paragraph)
(let ((cmds '("captionsetup" "caption"
"parencite" "par")))
(dolist (cmd cmds)
(search-forward (concat "\\" cmd))
(save-excursion
(end-of-line 0)
(fill-paragraph)))))
(buffer-string))
(with-temp-buffer
(insert-file-contents LaTeX-filling/out)
(buffer-string)))))
;; Test for bug#19281 (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19281):
;; make sure AUCTeX is able to insert and modify an environment containing a
;; TeX-esc and braces in its name.
(ert-deftest LaTeX-change-environment-with-esc ()
(should (string=
(with-temp-buffer
(LaTeX-mode)
(LaTeX-insert-environment (concat TeX-esc "foo{bar}"))
(LaTeX-modify-environment "foobar")
(buffer-string))
(with-temp-buffer
(LaTeX-mode)
(LaTeX-insert-environment "foobar")
(buffer-string)))))
;; Test for inserting &'s with `M-RET' in various tabular environment.
;; Following styles are loaded: tabularx, tabulary, longtable,
;; dcolumn, siunitx
(ert-deftest LaTeX-count-ampersands-inserted-in-tabular ()
(should (string=
(with-temp-buffer
(insert-file-contents tabular-count-ampersands/in)
(setq TeX-parse-self t)
(LaTeX-mode)
(goto-char (point-min))
;; Do not ask for opt. argument in (TeX-insert-macro "\\"):
(let ((TeX-insert-macro-default-style 'mandatory-args-only))
(while (search-forward "LaTeX-insert-item" nil t)
(LaTeX-insert-item)))
(buffer-string))
(with-temp-buffer
(insert-file-contents tabular-count-ampersands/out)
(LaTeX-mode)
(buffer-string)))))
(ert-deftest LaTeX-addbibresource ()
"Check parsing of bibliography files added with addbibresource.
In particular, make sure dots are treated correctly and only the
last extension is stripped."
(should
(equal
(with-temp-buffer
(insert "\\addbibresource{../foo-1.bar_2.qux3.ext}")
(LaTeX-mode)
(let ((TeX-parse-self t))
(TeX-update-style t))
(LaTeX-bibliography-list))
'(("../foo-1.bar_2.qux3")))))
;;; latex-test.el ends here

View File

@@ -0,0 +1,17 @@
\[
x
\]
\[
\begin{split}
x &= y \\
y &= z
\end{split}
\]
\begin{itemize}
\item Some text here
\[
x
\]
\end{itemize}

View File

@@ -0,0 +1,17 @@
\[
x
\]
\[
\begin{split}
x &= y \\
y &= z
\end{split}
\]
\begin{itemize}
\item Some text here
\[
x
\]
\end{itemize}

View File

@@ -0,0 +1,84 @@
\documentclass{article}
\usepackage{tabularx,tabulary,longtable,dcolumn,siunitx}
\begin{document}
Standard LaTeX tabular:
\begin{tabular}[t]{llll}
1 & 2 & 3 & LaTeX-insert-item
\end{tabular}
LaTeX tabular with *-operator:
\begin{tabular}[t]{*{3}{l}r}
1 & 2 & 3 & LaTeX-insert-item
\end{tabular}
\begin{tabular}{*{3}{l}>{\tiny\hfill}l<{\hfill}}
1 & 2 & 3 & LaTeX-insert-item
\end{tabular}
\begin{tabular}[t]{*{3}{lc}r}
1 & 2 & 3 & 4 & 5 & 6 & LaTeX-insert-item
\end{tabular}
\begin{tabular}[t]{*{3}{lc*{2}{l}} r}
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & LaTeX-insert-item
\end{tabular}
Standard LaTeX tabular*:
\begin{tabular*}{1.0\linewidth}[t]{@{}lllr@{}}
1 & 2 & 3 & LaTeX-insert-item
\end{tabular*}
\begin{tabular*}{1.0\linewidth}[t]{@{}*{3}{|l}|r|}
1 & 2 & 3 & LaTeX-insert-item
\end{tabular*}
tabularx:
\begin{tabularx}{1.0\linewidth}{llX}
1 & 2 & LaTeX-insert-item
\end{tabularx}
\begin{tabularx}{1.0\linewidth}[t]{@{}>{\tiny\hfill}l<{\hfill}lX@{}}
1 & 2 & LaTeX-insert-item
\end{tabularx}
\begin{tabularx}{1.0\linewidth}[t]{*{3}{|>{\tiny\hfill}X<{\hfill}}l}
1 & 2 & 3 & LaTeX-insert-item
\end{tabularx}
longtable:
\begin{longtable}[l]{llr}
\caption{Some caption}\\
1 & 2 & LaTeX-insert-item
\end{longtable}
\begin{longtable}[c]{*{3}{l}r}
\caption{Some caption}\\
1 & 2 & 3 & LaTeX-insert-item
\end{longtable}
\begin{longtable}[r]{*{3}{lc*{2}{l}} r}
\caption{Some caption}\\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & LaTeX-insert-item
\end{longtable}
dcolumn:
\begin{tabular}{D{,}{,}{2}D{,}{,}{2}D{,}{,}{2}}
1 & 2 & LaTeX-insert-item
\end{tabular}
\begin{tabular}{*{3}{D{,}{,}{2}}}
1 & 2 & LaTeX-insert-item
\end{tabular}
siunitx:
\begin{tabular}{%
s
S[table-number-alignment = center]
s[table-number-alignment = left]
S[table-number-alignment = right]
}
1 & 2 & 3 & LaTeX-insert-item
\end{tabular}
\end{document}

View File

@@ -0,0 +1,100 @@
\documentclass{article}
\usepackage{tabularx,tabulary,longtable,dcolumn,siunitx}
\begin{document}
Standard LaTeX tabular:
\begin{tabular}[t]{llll}
1 & 2 & 3 & LaTeX-insert-item \\
&&&
\end{tabular}
LaTeX tabular with *-operator:
\begin{tabular}[t]{*{3}{l}r}
1 & 2 & 3 & LaTeX-insert-item \\
&&&
\end{tabular}
\begin{tabular}{*{3}{l}>{\tiny\hfill}l<{\hfill}}
1 & 2 & 3 & LaTeX-insert-item \\
&&&
\end{tabular}
\begin{tabular}[t]{*{3}{lc}r}
1 & 2 & 3 & 4 & 5 & 6 & LaTeX-insert-item \\
&&&&&&
\end{tabular}
\begin{tabular}[t]{*{3}{lc*{2}{l}} r}
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & LaTeX-insert-item \\
&&&&&&&&&&&&
\end{tabular}
Standard LaTeX tabular*:
\begin{tabular*}{1.0\linewidth}[t]{@{}lllr@{}}
1 & 2 & 3 & LaTeX-insert-item \\
&&&
\end{tabular*}
\begin{tabular*}{1.0\linewidth}[t]{@{}*{3}{|l}|r|}
1 & 2 & 3 & LaTeX-insert-item \\
&&&
\end{tabular*}
tabularx:
\begin{tabularx}{1.0\linewidth}{llX}
1 & 2 & LaTeX-insert-item \\
&&
\end{tabularx}
\begin{tabularx}{1.0\linewidth}[t]{@{}>{\tiny\hfill}l<{\hfill}lX@{}}
1 & 2 & LaTeX-insert-item \\
&&
\end{tabularx}
\begin{tabularx}{1.0\linewidth}[t]{*{3}{|>{\tiny\hfill}X<{\hfill}}l}
1 & 2 & 3 & LaTeX-insert-item \\
&&&
\end{tabularx}
longtable:
\begin{longtable}[l]{llr}
\caption{Some caption}\\
1 & 2 & LaTeX-insert-item \\
&&
\end{longtable}
\begin{longtable}[c]{*{3}{l}r}
\caption{Some caption}\\
1 & 2 & 3 & LaTeX-insert-item \\
&&&
\end{longtable}
\begin{longtable}[r]{*{3}{lc*{2}{l}} r}
\caption{Some caption}\\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & LaTeX-insert-item \\
&&&&&&&&&&&&
\end{longtable}
dcolumn:
\begin{tabular}{D{,}{,}{2}D{,}{,}{2}D{,}{,}{2}}
1 & 2 & LaTeX-insert-item \\
&&
\end{tabular}
\begin{tabular}{*{3}{D{,}{,}{2}}}
1 & 2 & LaTeX-insert-item \\
&&
\end{tabular}
siunitx:
\begin{tabular}{%
s
S[table-number-alignment = center]
s[table-number-alignment = left]
S[table-number-alignment = right]
}
1 & 2 & 3 & LaTeX-insert-item \\
&&&
\end{tabular}
\end{document}

View File

@@ -0,0 +1,82 @@
\documentclass{article}
\begin{document}
\begin{tabular}{llll}
Lorem ipsum dolor & sit amet, ei mei
paulo tation honestatis,
intellegam & accommodare ne vim, ut
mel solum putant
atomorum. Posse & dolores has ut,\\
prompta & disputando & ne mel, ne
viderer ceteros
vel. & No petentium
\\
reformidans mel. & Quo no sale
natum, cu
pericula & deterruisset
usu. Nec & bonorum detracto\\
detraxit & no. & Ne sea doming & deserunt.
\end{tabular}
\begin{tabular}{ll}
1 & 2 & 3
\\
& 4 & 5
\\
6 & 7
& 8\\
9 &
10
& 11
\end{tabular}
\begin{align}
1 & 2
3 & 4
5\\
6 &
7
8 &
9
\end{align}
% Next table tests filling with a control symbol \& inside a cell; the
% function `LaTeX-indent-tabular' now (March 2017) detects \&, see:
% https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010
\begin{tabular}{llll}
Lorem ipsum dolor & sit amet, ei mei \&
paulo tation honestatis, \&
intellegam & accommodare ne vim, ut
mel solum putant
atomorum. Posse & dolores has ut,\\
prompta & disputando & ne mel, ne
\& viderer ceteros
vel. & No petentium
\end{tabular}
% Next tables test filling when & (column separator) character is
% missing in a row; the function `LaTeX-hanging-ampersand-position'
% now (March 2017) detects this and has a fallback, see:
% https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
\begin{tabular}{llll}
\multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei} \\
& paulo tation honestatis,
intellegam accommodare ne vim, ut \\
& mel solum putant atomorum. Posse & dolores has ut, \\
prompta & disputando & ne mel, ne
\& viderer ceteros vel. \\
& No petentium
\end{tabular}
\begin{table}[tbp]
\begin{tabular}{llll}
\multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei} \\
& paulo tation honestatis,
intellegam accommodare ne vim, ut \\
& mel solum putant atomorum. Posse & dolores has ut, \\
prompta & disputando & ne mel, ne
\& viderer ceteros vel. \\
& No petentium
\end{tabular}
\end{table}
\end{document}

View File

@@ -0,0 +1,82 @@
\documentclass{article}
\begin{document}
\begin{tabular}{llll}
Lorem ipsum dolor & sit amet, ei mei
paulo tation honestatis,
intellegam & accommodare ne vim, ut
mel solum putant
atomorum. Posse & dolores has ut,\\
prompta & disputando & ne mel, ne
viderer ceteros
vel. & No petentium
\\
reformidans mel. & Quo no sale
natum, cu
pericula & deterruisset
usu. Nec & bonorum detracto\\
detraxit & no. & Ne sea doming & deserunt.
\end{tabular}
\begin{tabular}{ll}
1 & 2 & 3
\\
& 4 & 5
\\
6 & 7
& 8\\
9 &
10
& 11
\end{tabular}
\begin{align}
1 & 2
3 & 4
5\\
6 &
7
8 &
9
\end{align}
% Next table tests filling with a control symbol \& inside a cell; the
% function `LaTeX-indent-tabular' now (March 2017) detects \&, see:
% https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010
\begin{tabular}{llll}
Lorem ipsum dolor & sit amet, ei mei \&
paulo tation honestatis, \&
intellegam & accommodare ne vim, ut
mel solum putant
atomorum. Posse & dolores has ut,\\
prompta & disputando & ne mel, ne
\& viderer ceteros
vel. & No petentium
\end{tabular}
% Next tables test filling when & (column separator) character is
% missing in a row; the function `LaTeX-hanging-ampersand-position'
% now (March 2017) detects this and has a fallback, see:
% https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
\begin{tabular}{llll}
\multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei} \\
& paulo tation honestatis,
intellegam accommodare ne vim, ut \\
& mel solum putant atomorum. Posse & dolores has ut, \\
prompta & disputando & ne mel, ne
\& viderer ceteros vel. \\
& No petentium
\end{tabular}
\begin{table}[tbp]
\begin{tabular}{llll}
\multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei} \\
& paulo tation honestatis,
intellegam accommodare ne vim, ut \\
& mel solum putant atomorum. Posse & dolores has ut, \\
prompta & disputando & ne mel, ne
\& viderer ceteros vel. \\
& No petentium
\end{tabular}
\end{table}
\end{document}