11
11
from __init__ import DocutilsTestSupport
13
from docutils._compat import b
14
16
settings = {'use_latex_toc': 0}
15
17
s = DocutilsTestSupport.PublishTestSuite('latex', suite_settings=settings)
16
18
s.generateTests(totest)
17
19
settings['use_latex_toc'] = 1
18
20
s.generateTests(totest_latex_toc)
21
settings['use_latex_toc'] = 0
22
settings['sectnum_xform'] = 0
23
s.generateTests(totest_latex_sectnum)
24
settings['sectnum_xform'] = 1
19
25
settings['use_latex_citations'] = 1
20
26
s.generateTests(totest_latex_citations)
25
\\documentclass[10pt,a4paper,english]{article}
29
\\usepackage{shortvrb}
30
\\usepackage[latin1]{inputenc}
31
\\usepackage{tabularx}
32
\\usepackage{longtable}
33
\\setlength{\\extrarowheight}{2pt}
35
\\usepackage{graphicx}
37
\\usepackage{multirow}
39
\\usepackage[DIV12]{typearea}
40
% generated by Docutils <http://docutils.sourceforge.net/>
41
\\newlength{\\admonitionwidth}
42
\\setlength{\\admonitionwidth}{0.9\\textwidth}
43
\\newlength{\\docinfowidth}
44
\\setlength{\\docinfowidth}{0.9\\textwidth}
45
\\newlength{\\locallinewidth}
46
\\newcommand{\\optionlistlabel}[1]{\\bf #1 \\hfill}
47
\\newenvironment{optionlist}[1]
49
{\\setlength{\\labelwidth}{#1}
50
\\setlength{\\rightmargin}{1cm}
51
\\setlength{\\leftmargin}{\\rightmargin}
52
\\addtolength{\\leftmargin}{\\labelwidth}
53
\\addtolength{\\leftmargin}{\\labelsep}
54
\\renewcommand{\\makelabel}{\\optionlistlabel}}
56
\\newlength{\\lineblockindentation}
57
\\setlength{\\lineblockindentation}{2.5em}
58
\\newenvironment{lineblock}[1]
60
{\\setlength{\\partopsep}{\\parskip}
61
\\addtolength{\\partopsep}{\\baselineskip}
62
\\topsep0pt\\itemsep0.15\\baselineskip\\parsep0pt
66
% begin: floats for footnotes tweaking.
67
\\setlength{\\floatsep}{0.5em}
68
\\setlength{\\textfloatsep}{\\fill}
69
\\addtolength{\\textfloatsep}{3em}
70
\\renewcommand{\\textfraction}{0.5}
71
\\renewcommand{\\topfraction}{0.5}
72
\\renewcommand{\\bottomfraction}{0.5}
73
\\setcounter{totalnumber}{50}
74
\\setcounter{topnumber}{50}
75
\\setcounter{bottomnumber}{50}
76
% end floats for footnotes
77
% some commands, that could be overwritten in the style file.
78
\\newcommand{\\rubric}[1]{\\subsection*{~\\hfill {\\it #1} \\hfill ~}}
79
\\newcommand{\\titlereference}[1]{\\textsl{#1}}
80
% end of "some commands"
81
\\ifthenelse{\\isundefined{\\hypersetup}}{
82
\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
29
latex_head_prefix = b(
30
r"""% generated by Docutils <http://docutils.sourceforge.net/>
31
\documentclass[a4paper,english]{article}
32
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
33
\usepackage{cmap} % fix search and cut-and-paste in PDF
35
\usepackage[T1]{fontenc}
36
\usepackage[latin1]{inputenc}
40
latex_requirements = b('')
43
%%% User specified packages and stylesheets
45
%%% Fallback definitions for Docutils-specific commands
48
\ifthenelse{\isundefined{\hypersetup}}{
49
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
53
latex_head_DUtitle = b(r"""
54
%%% User specified packages and stylesheets
56
%%% Fallback definitions for Docutils-specific commands
58
% title for topics, admonitions and sidebar
59
\providecommand*{\DUtitle}[2][class-arg]{%
60
% call \DUtitle#1{#2} if it exists:
61
\ifcsname DUtitle#1\endcsname%
62
\csname DUtitle#1\endcsname{#2}%
64
\smallskip\noindent\textbf{#2}\smallskip%
69
\ifthenelse{\isundefined{\hypersetup}}{
70
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
74
latex_requirements_table = b(r"""\usepackage{longtable}
76
\setlength{\extrarowheight}{2pt}
77
\newlength{\DUtablewidth} % internal use in tables
87
82
totest_latex_toc = {}
83
totest_latex_sectnum = {}
88
84
totest_latex_citations = {}
90
86
totest['url_chars'] = [
91
87
["http://nowhere/url_with%28parens%29",
99
\\setlength{\\locallinewidth}{\\linewidth}
101
\\href{http://nowhere/url_with\\%28parens\\%29}{http://nowhere/url{\\_}with{\\%}28parens{\\%}29}
88
latex_head_prefix + latex_requirements + latex_head + b(r"""
92
\href{http://nowhere/url_with\%28parens\%29}{http://nowhere/url\_with\%28parens\%29}
107
98
totest['table_of_contents'] = [
120
111
## # expected output
128
\\setlength{\\locallinewidth}{\\linewidth}
129
\\hypertarget{table-of-contents}{}
130
\\pdfbookmark[0]{Table of Contents}{table-of-contents}
131
\\subsubsection*{~\\hfill Table of Contents\\hfill ~}
132
\\label{table-of-contents}
134
\\item {} \\href{\\#title-1}{Title 1}
136
\\item {} \\href{\#title-2}{Title 2}
144
%___________________________________________________________________________
146
\\hypertarget{title-1}{}
147
\\pdfbookmark[0]{Title 1}{title-1}
154
%___________________________________________________________________________
156
\\hypertarget{title-2}{}
157
\\pdfbookmark[1]{Title 2}{title-2}
158
\\subsection*{Title 2}
168
totest_latex_toc['table_of_contents'] = [
171
.. contents:: Table of Contents
189
\\setlength{\\locallinewidth}{\\linewidth}
190
\\hypertarget{table-of-contents}{}
191
\\renewcommand{\contentsname}{Table of Contents}
195
\\label{table-of-contents}
198
%___________________________________________________________________________
200
\\hypertarget{title-1}{}
207
%___________________________________________________________________________
209
\\hypertarget{title-2}{}
210
\\subsection{Title 2}
112
latex_head_prefix + latex_requirements + latex_head_DUtitle + b(r"""
116
\phantomsection\label{table-of-contents}
117
\pdfbookmark[1]{Table of Contents}{table-of-contents}
118
\DUtitle[contents]{Table of Contents}
122
\item \hyperref[title-1]{Title 1}
126
\item \hyperref[title-2]{Title 2}
133
%___________________________________________________________________________
137
\addcontentsline{toc}{section}{Title 1}%
144
%___________________________________________________________________________
146
\subsection*{Title 2%
148
\addcontentsline{toc}{subsection}{Title 2}%
159
totest_latex_toc['no_sectnum'] = [
168
latex_head_prefix + latex_requirements + latex_head + b(r"""
172
\phantomsection\label{contents}
173
\pdfbookmark[1]{Contents}{contents}
178
%___________________________________________________________________________
180
\section*{first section%
182
\addcontentsline{toc}{section}{first section}%
183
\label{first-section}%
190
totest_latex_toc['sectnum'] = [
200
latex_head_prefix + latex_requirements + latex_head + b(r"""
204
\phantomsection\label{contents}
205
\pdfbookmark[1]{Contents}{contents}
210
%___________________________________________________________________________
212
\section*{1~~~first section%
214
\addcontentsline{toc}{section}{1~~~first section}%
215
\label{first-section}%
223
totest_latex_sectnum['no_sectnum'] = [
232
latex_head_prefix + latex_requirements + b(r"""\setcounter{secnumdepth}{0}
233
""") + latex_head + b(r"""
240
%___________________________________________________________________________
242
\section{first section%
243
\label{first-section}%
250
totest_latex_sectnum['sectnum'] = [
261
latex_head_prefix + latex_requirements + latex_head + b(r"""
268
%___________________________________________________________________________
270
\section{first section%
271
\label{first-section}%
221
278
totest_latex_citations['citations_with_underscore'] = [
227
284
The underscore is mishandled.
229
286
## # expected output
237
\\setlength{\\locallinewidth}{\\linewidth}
239
Just a test citation \\cite{my_cite2006}.
241
\\begin{thebibliography}{my{\\_}cite2006}
242
\\bibitem[my{\\_}cite2006]{my_cite2006}{
287
latex_head_prefix + latex_requirements + latex_head + b(r"""
291
Just a test citation \cite{my_cite2006}.
293
\begin{thebibliography}{my\_cite2006}
294
\bibitem[my\_cite2006]{my_cite2006}{
243
295
The underscore is mishandled.
245
\\end{thebibliography}
297
\end{thebibliography}
304
totest_latex_citations['adjacent_citations'] = [
307
Two non-citations: [MeYou2007]_[YouMe2007]_.
309
Need to be separated for grouping: [MeYou2007]_ [YouMe2007]_.
311
Two spaces (or anything else) for no grouping: [MeYou2007]_ [YouMe2007]_.
313
But a line break should work: [MeYou2007]_
317
.. [YouMe2007] important.
320
latex_head_prefix + latex_requirements + latex_head + b(r"""
324
Two non-citations: {[}MeYou2007{]}\_{[}YouMe2007{]}\_.
326
Need to be separated for grouping: \cite{MeYou2007,YouMe2007}.
328
Two spaces (or anything else) for no grouping: \cite{MeYou2007} \cite{YouMe2007}.
330
But a line break should work: \cite{MeYou2007,YouMe2007}.
332
\begin{thebibliography}{MeYou2007}
333
\bibitem[MeYou2007]{MeYou2007}{
336
\bibitem[YouMe2007]{YouMe2007}{
339
\end{thebibliography}
264
358
(II) in roman numerals.
266
360
# expected output
274
\\setlength{\\locallinewidth}{\\linewidth}
275
\\newcounter{listcnt0}
276
\\begin{list}{\\arabic{listcnt0}.}
278
\\usecounter{listcnt0}
279
\\setlength{\\rightmargin}{\\leftmargin}
285
Second to the previous item this one will explain
289
\\setcounter{listcnt0}{0}
290
\\begin{list}{\\alph{listcnt0})}
292
\\usecounter{listcnt0}
293
\\setlength{\\rightmargin}{\\leftmargin}
303
\\setcounter{listcnt0}{0}
304
\\begin{list}{\\arabic{listcnt0}.}
306
\\usecounter{listcnt0}
307
\\addtocounter{listcnt0}{2}
308
\\setlength{\\rightmargin}{\\leftmargin}
315
\\setcounter{listcnt0}{0}
316
\\begin{list}{(\\Roman{listcnt0})}
318
\\usecounter{listcnt0}
319
\\setlength{\\rightmargin}{\\leftmargin}
322
having pre and postfixes
361
latex_head_prefix + latex_requirements + latex_head + b(r"""
364
\newcounter{listcnt0}
365
\begin{list}{\arabic{listcnt0}.}
367
\usecounter{listcnt0}
368
\setlength{\rightmargin}{\leftmargin}
373
\item Second to the previous item this one will explain
377
\setcounter{listcnt0}{0}
378
\begin{list}{\alph{listcnt0})}
380
\usecounter{listcnt0}
381
\setlength{\rightmargin}{\leftmargin}
390
\setcounter{listcnt0}{0}
391
\begin{list}{\arabic{listcnt0}.}
393
\usecounter{listcnt0}
394
\addtocounter{listcnt0}{2}
395
\setlength{\rightmargin}{\leftmargin}
402
\setcounter{listcnt0}{0}
403
\begin{list}{(\Roman{listcnt0})}
405
\usecounter{listcnt0}
406
\setlength{\rightmargin}{\leftmargin}
409
\item having pre and postfixes
411
\item in roman numerals.
334
420
# BUG: need to test for quote replacing if language is de (ngerman).