4 # Author: engelbert gruber <grubert@users.sourceforge.net>
5 # Copyright: This module has been placed in the public domain.
8 Tests for latex2e writer.
11 from __init__
import DocutilsTestSupport
14 settings
= {'use_latex_toc': 0}
15 s
= DocutilsTestSupport
.PublishTestSuite('latex', suite_settings
=settings
)
16 s
.generateTests(totest
)
17 settings
['use_latex_toc'] = 1
18 s
.generateTests(totest_latex_toc
)
19 settings
['use_latex_citations'] = 1
20 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}
88 totest_latex_citations
= {}
90 totest
['table_of_contents'] = [
93 .. contents:: Table of Contents
111 \\setlength{\\locallinewidth}{\\linewidth}
112 \\hypertarget{table-of-contents}{}
113 \\pdfbookmark[0]{Table of Contents}{table-of-contents}
114 \\subsubsection*{~\\hfill Table of Contents\\hfill ~}
115 \\label{table-of-contents}
117 \\item {} \\href{\\#title-1}{Title 1}
119 \\item {} \\href{\#title-2}{Title 2}
127 %___________________________________________________________________________
129 \\hypertarget{title-1}{}
130 \\pdfbookmark[0]{Title 1}{title-1}
137 %___________________________________________________________________________
139 \\hypertarget{title-2}{}
140 \\pdfbookmark[1]{Title 2}{title-2}
141 \\subsection*{Title 2}
151 totest_latex_toc
['table_of_contents'] = [
154 .. contents:: Table of Contents
172 \\setlength{\\locallinewidth}{\\linewidth}
173 \\hypertarget{table-of-contents}{}
174 \\renewcommand{\contentsname}{Table of Contents}
178 \\label{table-of-contents}
181 %___________________________________________________________________________
183 \\hypertarget{title-1}{}
190 %___________________________________________________________________________
192 \\hypertarget{title-2}{}
193 \\subsection{Title 2}
204 totest_latex_citations
['citations_with_underscore'] = [
207 Just a test citation [my_cite2006]_.
210 The underscore is mishandled.
220 \\setlength{\\locallinewidth}{\\linewidth}
222 Just a test citation \\cite{my_cite2006}.
224 \\begin{thebibliography}{my{\\_}cite2006}
225 \\bibitem[my{\\_}cite2006]{my_cite2006}{
226 The underscore is mishandled.
228 \\end{thebibliography}
235 totest
['enumerated_lists'] = [
239 2. Second to the previous item this one will explain
246 (I) having pre and postfixes
247 (II) in roman numerals.
257 \\setlength{\\locallinewidth}{\\linewidth}
258 \\newcounter{listcnt0}
259 \\begin{list}{\\arabic{listcnt0}.}
261 \\usecounter{listcnt0}
262 \\setlength{\\rightmargin}{\\leftmargin}
268 Second to the previous item this one will explain
272 \\setcounter{listcnt0}{0}
273 \\begin{list}{\\alph{listcnt0})}
275 \\usecounter{listcnt0}
276 \\setlength{\\rightmargin}{\\leftmargin}
286 \\setcounter{listcnt0}{0}
287 \\begin{list}{\\arabic{listcnt0}.}
289 \\usecounter{listcnt0}
290 \\addtocounter{listcnt0}{2}
291 \\setlength{\\rightmargin}{\\leftmargin}
298 \\setcounter{listcnt0}{0}
299 \\begin{list}{(\\Roman{listcnt0})}
301 \\usecounter{listcnt0}
302 \\setlength{\\rightmargin}{\\leftmargin}
305 having pre and postfixes
317 # BUG: need to test for quote replacing if language is de (ngerman).
319 totest
['quote_mangling'] = [
322 Depending on language quotes are converted for latex.
325 Inside literal blocks quotes should be left untouched
326 (use only two quotes in test code makes life easier for
327 the python interpreter running the test)::
330 This is left "untouched" also *this*.
335 should get "quotes" and *italics*.
338 Inline ``literal "quotes"`` should be kept.
347 \\setlength{\\locallinewidth}{\\linewidth}
349 Depending on language quotes are converted for latex.
350 Expecting ``en'' here.
352 Inside literal blocks quotes should be left untouched
353 (use only two quotes in test code makes life easier for
354 the python interpreter running the test):
355 \\begin{quote}{\\ttfamily \\raggedright \\noindent
357 This~is~left~"untouched"~also~*this*.~\\\\
360 \\begin{quote}{\\ttfamily \\raggedright \\noindent
361 should~get~"quotes"~and~\\emph{italics}.
364 Inline \\texttt{literal "quotes"} should be kept.
370 totest
['table_caption'] = [
388 \\setlength{\\locallinewidth}{\\linewidth}
391 \\begin{longtable}[c]{|p{0.075\locallinewidth}|p{0.075\locallinewidth}|}
404 totest
['table_class'] = [
423 \\setlength{\\locallinewidth}{\\linewidth}
426 \\begin{longtable}[c]{p{0.075\locallinewidth}p{0.075\locallinewidth}}
443 # In "\\\n[" the "[" needs to be protected (otherwise it will be seen as an option to "\\").
444 totest
['brackett_protection'] = [
449 something before to get a end of line.
452 the empty line gets tested too
462 \\setlength{\\locallinewidth}{\\linewidth}
463 \\begin{quote}{\\ttfamily \\raggedright \\noindent
464 something~before~to~get~a~end~of~line.~\\\\
467 the~empty~line~gets~tested~too~\\\\
497 \\setlength{\\locallinewidth}{\\linewidth}
508 if __name__
== '__main__':
510 unittest
.main(defaultTest
='suite')