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
)
23 \\documentclass[10pt,a4paper,english]{article}
27 \\usepackage{shortvrb}
28 \\usepackage[latin1]{inputenc}
29 \\usepackage{tabularx}
30 \\usepackage{longtable}
31 \\setlength{\\extrarowheight}{2pt}
33 \\usepackage{graphicx}
35 \\usepackage{multirow}
37 \\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
38 \\usepackage[DIV12]{typearea}
39 %% generator Docutils: http://docutils.sourceforge.net/
40 \\newlength{\\admonitionwidth}
41 \\setlength{\\admonitionwidth}{0.9\\textwidth}
42 \\newlength{\\docinfowidth}
43 \\setlength{\\docinfowidth}{0.9\\textwidth}
44 \\newlength{\\locallinewidth}
45 \\newcommand{\\optionlistlabel}[1]{\\bf #1 \\hfill}
46 \\newenvironment{optionlist}[1]
48 {\\setlength{\\labelwidth}{#1}
49 \\setlength{\\rightmargin}{1cm}
50 \\setlength{\\leftmargin}{\\rightmargin}
51 \\addtolength{\\leftmargin}{\\labelwidth}
52 \\addtolength{\\leftmargin}{\\labelsep}
53 \\renewcommand{\\makelabel}{\\optionlistlabel}}
55 \\newlength{\\lineblockindentation}
56 \\setlength{\\lineblockindentation}{2.5em}
57 \\newenvironment{lineblock}[1]
59 {\\setlength{\\partopsep}{\\parskip}
60 \\addtolength{\\partopsep}{\\baselineskip}
61 \\topsep0pt\\itemsep0.15\\baselineskip\\parsep0pt
65 % begin: floats for footnotes tweaking.
66 \\setlength{\\floatsep}{0.5em}
67 \\setlength{\\textfloatsep}{\\fill}
68 \\addtolength{\\textfloatsep}{3em}
69 \\renewcommand{\\textfraction}{0.5}
70 \\renewcommand{\\topfraction}{0.5}
71 \\renewcommand{\\bottomfraction}{0.5}
72 \\setcounter{totalnumber}{50}
73 \\setcounter{topnumber}{50}
74 \\setcounter{bottomnumber}{50}
75 % end floats for footnotes
76 % some commands, that could be overwritten in the style file.
77 \\newcommand{\\rubric}[1]{\\subsection*{~\\hfill {\\it #1} \\hfill ~}}
78 \\newcommand{\\titlereference}[1]{\\textsl{#1}}
79 % end of "some commands"
85 totest
['table_of_contents'] = [
88 .. contents:: Table of Contents
106 \\setlength{\\locallinewidth}{\\linewidth}
107 \\hypertarget{table-of-contents}{}
108 \\pdfbookmark[0]{Table of Contents}{table-of-contents}
109 \\subsubsection*{~\\hfill Table of Contents\\hfill ~}
111 \\item {} \\href{\\#title-1}{Title 1}
113 \\item {} \\href{\#title-2}{Title 2}
121 %___________________________________________________________________________
123 \\hypertarget{title-1}{}
124 \\pdfbookmark[0]{Title 1}{title-1}
130 %___________________________________________________________________________
132 \\hypertarget{title-2}{}
133 \\pdfbookmark[1]{Title 2}{title-2}
134 \\subsection*{Title 2}
143 totest_latex_toc
['table_of_contents'] = [
146 .. contents:: Table of Contents
164 \\setlength{\\locallinewidth}{\\linewidth}
165 \\hypertarget{table-of-contents}{}
166 \\renewcommand{\contentsname}{Table of Contents}
172 %___________________________________________________________________________
174 \\hypertarget{title-1}{}
180 %___________________________________________________________________________
182 \\hypertarget{title-2}{}
183 \\subsection{Title 2}
193 totest
['enumerated_lists'] = [
197 2. Second to the previous item this one will explain
204 (I) having pre and postfixes
205 (II) in roman numerals.
215 \\setlength{\\locallinewidth}{\\linewidth}
216 \\newcounter{listcnt0}
217 \\begin{list}{\\arabic{listcnt0}.}
219 \\usecounter{listcnt0}
220 \\setlength{\\rightmargin}{\\leftmargin}
226 Second to the previous item this one will explain
230 \\setcounter{listcnt0}{0}
231 \\begin{list}{\\alph{listcnt0})}
233 \\usecounter{listcnt0}
234 \\setlength{\\rightmargin}{\\leftmargin}
244 \\setcounter{listcnt0}{0}
245 \\begin{list}{\\arabic{listcnt0}.}
247 \\usecounter{listcnt0}
248 \\addtocounter{listcnt0}{2}
249 \\setlength{\\rightmargin}{\\leftmargin}
256 \\setcounter{listcnt0}{0}
257 \\begin{list}{(\\Roman{listcnt0})}
259 \\usecounter{listcnt0}
260 \\setlength{\\rightmargin}{\\leftmargin}
263 having pre and postfixes
275 # BUG: need to test for quote replacing if language is de (ngerman).
277 totest
['quote_mangling'] = [
280 Depending on language quotes are converted for latex.
283 Inside literal blocks quotes should be left untouched
284 (use only two quotes in test code makes life easier for
285 the python interpreter running the test)::
288 This is left "untouched" also *this*.
293 should get "quotes" and *italics*.
296 Inline ``literal "quotes"`` should be kept.
305 \\setlength{\\locallinewidth}{\\linewidth}
307 Depending on language quotes are converted for latex.
308 Expecting ``en'' here.
310 Inside literal blocks quotes should be left untouched
311 (use only two quotes in test code makes life easier for
312 the python interpreter running the test):
313 \\begin{quote}{\\ttfamily \\raggedright \\noindent
315 This~is~left~"untouched"~also~*this*.~\\\\
318 \\begin{quote}{\\ttfamily \\raggedright \\noindent
319 should~get~"quotes"~and~\\emph{italics}.
322 Inline \\texttt{literal "quotes"} should be kept.
328 totest
['table_caption'] = [
346 \\setlength{\\locallinewidth}{\\linewidth}
348 \\begin{longtable}[c]{|p{0.07\locallinewidth}|p{0.07\locallinewidth}|}
361 totest
['table_class'] = [
380 \\setlength{\\locallinewidth}{\\linewidth}
382 \\begin{longtable}[c]{p{0.07\locallinewidth}p{0.07\locallinewidth}}
399 # In "\\\n[" the "[" needs to be protected (otherwise it will be seen as an option to "\\").
400 totest
['brackett_protection'] = [
405 something before to get a end of line.
408 the empty line gets tested too
418 \\setlength{\\locallinewidth}{\\linewidth}
419 \\begin{quote}{\\ttfamily \\raggedright \\noindent
420 something~before~to~get~a~end~of~line.~\\\\
423 the~empty~line~gets~tested~too~\\\\
453 \\setlength{\\locallinewidth}{\\linewidth}
464 if __name__
== '__main__':
466 unittest
.main(defaultTest
='suite')