1 /******************************************************************************
3 * $Id: latexgen.cpp,v 1.58 2001/03/19 19:27:40 root Exp $
5 * Copyright (C) 1997-2012 by Dimitri van Heesch.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
32 #include "docparser.h"
33 #include "latexdocvisitor.h"
37 //static QCString filterTitle(const char *s)
39 // QCString tmp=s,result;
40 // uint i;for (i=0;i<tmp.length();i++)
45 // case '#': result+="\\#"; break;
46 // case '"': result+="\\\""; break;
47 // case '%': result+="\\%"; break;
48 // case '[': result+="{"; break;
49 // case ']': result+="}"; break;
50 // default: result+=c; break;
58 LatexGenerator::LatexGenerator() : OutputGenerator()
60 dir=Config_getString("LATEX_OUTPUT");
62 //printf("LatexGenerator::LatexGenerator() insideTabbing=FALSE\n");
67 templateMemberItem = FALSE;
68 m_prettyCode=Config_getBool("LATEX_SOURCE_CODE");
71 LatexGenerator::~LatexGenerator()
75 static void writeLatexMakefile()
77 bool generateBib = !Doxygen::citeDict->isEmpty();
78 QCString dir=Config_getString("LATEX_OUTPUT");
79 QCString fileName=dir+"/Makefile";
81 if (!file.open(IO_WriteOnly))
83 err("Could not open file %s for writing\n",fileName.data());
86 // inserted by KONNO Akihisa <konno@researchers.jp> 2002-03-05
87 QCString latex_command = Config_getString("LATEX_CMD_NAME");
88 QCString mkidx_command = Config_getString("MAKEINDEX_CMD_NAME");
89 // end insertion by KONNO Akihisa <konno@researchers.jp> 2002-03-05
91 if (!Config_getBool("USE_PDFLATEX")) // use plain old latex
93 t << "all: refman.dvi" << endl
95 << "ps: refman.ps" << endl
97 << "pdf: refman.pdf" << endl
99 << "ps_2on1: refman_2on1.ps" << endl
101 << "pdf_2on1: refman_2on1.pdf" << endl
103 << "refman.ps: refman.dvi" << endl
104 << "\tdvips -o refman.ps refman.dvi" << endl
106 t << "refman.pdf: refman.ps" << endl;
107 t << "\tps2pdf refman.ps refman.pdf" << endl << endl;
108 t << "refman.dvi: clean refman.tex doxygen.sty" << endl
109 << "\techo \"Running latex...\"" << endl
110 << "\t" << latex_command << " refman.tex" << endl
111 << "\techo \"Running makeindex...\"" << endl
112 << "\t" << mkidx_command << " refman.idx" << endl;
115 t << "\techo \"Running bibtex...\"" << endl;
116 t << "\tbibtex refman" << endl;
117 t << "\techo \"Rerunning latex....\"" << endl;
118 t << "\t" << latex_command << " refman.tex" << endl;
120 t << "\techo \"Rerunning latex....\"" << endl
121 << "\t" << latex_command << " refman.tex" << endl
122 << "\tlatex_count=5 ; \\" << endl
123 << "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\" << endl
124 << "\t do \\" << endl
125 << "\t echo \"Rerunning latex....\" ;\\" << endl
126 << "\t " << latex_command << " refman.tex ;\\" << endl
127 << "\t latex_count=`expr $$latex_count - 1` ;\\" << endl
128 << "\t done" << endl << endl
129 << "refman_2on1.ps: refman.ps" << endl
130 << "\tpsnup -2 refman.ps >refman_2on1.ps" << endl
132 << "refman_2on1.pdf: refman_2on1.ps" << endl
133 << "\tps2pdf refman_2on1.ps refman_2on1.pdf" << endl;
135 else // use pdflatex for higher quality output
137 t << "all: refman.pdf" << endl << endl
138 << "pdf: refman.pdf" << endl << endl;
139 t << "refman.pdf: clean refman.tex" << endl;
140 t << "\tpdflatex refman" << endl;
141 t << "\t" << mkidx_command << " refman.idx" << endl;
144 t << "\tbibtex refman" << endl;
145 t << "\tpdflatex refman" << endl;
147 t << "\tpdflatex refman" << endl
148 << "\tlatex_count=5 ; \\" << endl
149 << "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\" << endl
150 << "\t do \\" << endl
151 << "\t echo \"Rerunning latex....\" ;\\" << endl
152 << "\t pdflatex refman ;\\" << endl
153 << "\t latex_count=`expr $$latex_count - 1` ;\\" << endl
154 << "\t done" << endl << endl;
160 << "*.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf" << endl;
163 static void writeMakeBat()
165 #if defined(_MSC_VER)
166 QCString dir=Config_getString("LATEX_OUTPUT");
167 QCString fileName=dir+"/make.bat";
168 QCString latex_command = Config_getString("LATEX_CMD_NAME");
169 QCString mkidx_command = Config_getString("MAKEINDEX_CMD_NAME");
170 QFile file(fileName);
171 bool generateBib = !Doxygen::citeDict->isEmpty();
172 if (!file.open(IO_WriteOnly))
174 err("Could not open file %s for writing\n",fileName.data());
177 FTextStream t(&file);
178 t << "del /s /f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf\n\n";
179 if (!Config_getBool("USE_PDFLATEX")) // use plain old latex
181 t << latex_command << " refman.tex\n";
183 t << mkidx_command << " refman.idx\n";
186 t << "bibtex refman\n";
188 t << latex_command << " refman.tex\n";
190 t << "setlocal enabledelayedexpansion\n";
191 t << "set count=5\n";
193 t << "set content=X\n";
194 t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" refman.log' ) do set content=\"%%~T\"\n";
195 t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" refman.log' ) do set content=\"%%~T\"\n";
196 t << "if !content! == X goto :skip\n";
197 t << "set /a count-=1\n";
198 t << "if !count! EQU 0 goto :skip\n\n";
200 t << latex_command << " refman.tex\n";
201 t << "goto :repeat\n";
204 t << "dvips -o refman.ps refman.dvi\n";
205 t << "gswin32c -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "
206 "-sOutputFile=refman.pdf -c save pop -f refman.ps\n";
210 t << "pdflatex refman\n";
212 t << mkidx_command << " refman.idx\n";
215 t << "bibtex refman" << endl;
216 t << "pdflatex refman" << endl;
219 t << "pdflatex refman\n\n";
220 t << "setlocal enabledelayedexpansion\n";
221 t << "set count=5\n";
223 t << "set content=X\n";
224 t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" refman.log' ) do set content=\"%%~T\"\n";
225 t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" refman.log' ) do set content=\"%%~T\"\n";
226 t << "if !content! == X goto :skip\n";
227 t << "set /a count-=1\n";
228 t << "if !count! EQU 0 goto :skip\n\n";
230 t << "pdflatex refman\n";
231 t << "goto :repeat\n";
238 void LatexGenerator::init()
241 QCString dir=Config_getString("LATEX_OUTPUT");
243 if (!d.exists() && !d.mkdir(dir))
245 err("Could not create output directory %s\n",dir.data());
249 writeLatexMakefile();
255 static void writeDefaultHeaderPart1(FTextStream &t)
260 if (Config_getBool("LATEX_BATCHMODE")) t << "\\batchmode" << endl;
261 QCString &paperType=Config_getEnum("PAPER_TYPE");
262 if (paperType=="a4wide")
266 t << "\\documentclass";
267 //"[" << paperName << "paper";
270 if (Config_getBool("COMPACT_LATEX")) t << "article"; else t << "book";
272 // the next package is obsolete (see bug 563698)
273 //if (paperType=="a4wide") t << "\\usepackage{a4wide}\n";
275 "\\usepackage["<<paperName<<"paper,top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm]{geometry}\n"
276 "\\usepackage{makeidx}\n"
277 "\\usepackage{natbib}\n"
278 "\\usepackage{graphicx}\n"
279 "\\usepackage{multicol}\n"
280 "\\usepackage{float}\n"
281 "\\usepackage{listings}\n"
282 "\\usepackage{color}\n"
283 "\\usepackage{ifthen}\n"
284 "\\usepackage[table]{xcolor}\n"
285 "\\usepackage{textcomp}\n"
286 "\\usepackage{alltt}\n"
287 //"\\usepackage{ae,aecompl,aeguill}\n"
289 //if (Config_getBool("USE_PDFLATEX"))
291 // t << "\\usepackage{times}" << endl;
293 if (Config_getBool("PDF_HYPERLINKS"))
295 t << "\\usepackage{ifpdf}" << endl
297 << "\\usepackage[pdftex," << endl
298 << " pagebackref=true," << endl
299 << " colorlinks=true," << endl
300 << " linkcolor=blue," << endl
301 << " unicode" << endl
302 << " ]{hyperref}" << endl
304 << "\\usepackage[ps2pdf," << endl
305 << " pagebackref=true," << endl
306 << " colorlinks=true," << endl
307 << " linkcolor=blue," << endl
308 << " unicode" << endl
309 << " ]{hyperref}" << endl
310 << "\\usepackage{pspicture}" << endl
313 // Try to get the command for switching on the language
315 t << "\\usepackage[utf8]{inputenc}" << endl;
316 QCString sLanguageSupportCommand(
317 theTranslator->latexLanguageSupportCommand());
319 if (!sLanguageSupportCommand.isEmpty())
321 // The command is not empty. Put it to the output.
322 // if the command is empty, no output is needed.
323 t << sLanguageSupportCommand << endl;
325 t << "\\usepackage{mathptmx}\n";
326 t << "\\usepackage[scaled=.90]{helvet}\n";
327 t << "\\usepackage{courier}\n";
328 t << "\\usepackage{sectsty}\n";
329 t << "\\usepackage{amssymb}\n";
330 t << "\\usepackage[titles]{tocloft}\n";
331 t << "\\usepackage{doxygen}\n";
333 // define option for listings
334 t << "\\lstset{language=C++,"
335 "inputencoding=utf8,"
336 "basicstyle=\\footnotesize,"
338 "breakatwhitespace=true,"
339 "tabsize=" << Config_getInt("TAB_SIZE") <<","
340 "numbers=left }" << endl;
342 QStrList &extraPackages = Config_getList("EXTRA_PACKAGES");
343 const char *s=extraPackages.first();
346 t << "\\usepackage{" << s << "}\n";
347 s=extraPackages.next();
350 "\\setcounter{tocdepth}{3}\n"
351 "\\renewcommand{\\footrulewidth}{0.4pt}\n"
352 "\\renewcommand{\\familydefault}{\\sfdefault}\n"
353 "\\hfuzz=15pt\n" // allow a bit of overflow to go unnoticed
354 "\\setlength{\\emergencystretch}{15pt}\n"
357 "\\begin{document}\n";
358 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
359 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
360 if (pdfHyperlinks && usePDFLatex)
362 // to avoid duplicate page anchors due to reuse of same numbers for
363 // the index (be it as roman numbers)
364 t << "\\hypersetup{pageanchor=false,citecolor=blue}" << endl;
366 if (theTranslator->idLanguage()=="greek") t << "\\selectlanguage{greek}\n";
367 t << "\\begin{titlepage}\n"
374 static void writeDefaultHeaderPart2(FTextStream &t)
378 << "\\vspace*{1cm}" << endl
382 static void writeDefaultHeaderPart3(FTextStream &t)
385 t << " Doxygen " << versionString << "}\\\\" << endl
386 << "\\vspace*{0.5cm}" << endl
387 << "{\\small " << dateToString(TRUE) << "}\\\\" << endl
388 << "\\end{center}" << endl
389 << "\\end{titlepage}" << endl;
390 if (!Config_getBool("COMPACT_LATEX")) t << "\\clearemptydoublepage\n";
391 t << "\\pagenumbering{roman}\n";
392 t << "\\tableofcontents\n";
393 if (!Config_getBool("COMPACT_LATEX")) t << "\\clearemptydoublepage\n";
394 t << "\\pagenumbering{arabic}\n";
395 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
396 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
397 if (pdfHyperlinks && usePDFLatex)
399 t << "\\hypersetup{pageanchor=true,citecolor=blue}" << endl;
403 static void writeDefaultStyleSheetPart1(FTextStream &t)
406 t << "\\NeedsTeXFormat{LaTeX2e}\n"
407 "\\ProvidesPackage{doxygen}\n\n";
408 t << "% Packages used by this style file\n"
409 "\\RequirePackage{alltt}\n"
410 "\\RequirePackage{array}\n"
411 "\\RequirePackage{calc}\n"
412 "\\RequirePackage{color}\n"
413 "\\RequirePackage{fancyhdr}\n"
414 "\\RequirePackage{longtable}\n"
415 "\\RequirePackage{verbatim}\n"
416 "\\RequirePackage{ifthen}\n"
417 "\\RequirePackage{xtab}\n"
418 "\\RequirePackage{multirow}\n"
419 "\\RequirePackage[table]{xcolor}\n\n";
421 t << "% Use helvetica font instead of times roman\n"
422 "\\RequirePackage{helvet}\n"
423 "\\RequirePackage{sectsty}\n"
424 "\\RequirePackage{tocloft}\n"
425 // "\\allsectionsfont{\\usefont{OT1}{phv}{bc}{n}\\selectfont}\n"
426 // "\\providecommand{\\cftchapfont}{%\n"
427 // " \\fontsize{11}{13}\\usefont{OT1}{phv}{bc}{n}\\selectfont\n"
429 // "\\providecommand{\\cftchappagefont}{%\n"
430 // " \\fontsize{11}{13}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
432 // "\\providecommand{\\cftsecfont}{%\n"
433 // " \\fontsize{10}{12}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
435 // "\\providecommand{\\cftsecpagefont}{%\n"
436 // " \\fontsize{10}{12}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
438 // "\\providecommand{\\cftsubsecfont}{%\n"
439 // " \\fontsize{10}{12}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
441 // "\\providecommand{\\cftsubsecpagefont}{%\n"
442 // " \\fontsize{10}{12}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
444 // "\\providecommand{\\cftsubsubsecfont}{%\n"
445 // " \\fontsize{9}{11}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
447 // "\\providecommand{\\cftsubsubsecpagefont}{%\n"
448 // " \\fontsize{9}{11}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
450 // "\\providecommand{\\cftparafont}{%\n"
451 // " \\fontsize{9}{11}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
453 // "\\providecommand{\\cftparapagefont}{%\n"
454 // " \\fontsize{9}{11}\\usefont{OT1}{phv}{c}{n}\\selectfont\n"
456 // "\\providecommand{\\cfttoctitlefont}{%\n"
457 // " \\fontsize{20}{22}\\usefont{OT1}{phv}{b}{n}\\selectfont\n"
459 "\\providecommand{\\rmdefault}{phv}\n"
460 "\\providecommand{\\bfdefault}{bc}\n"
463 t << "% Setup fancy headings\n"
464 "\\pagestyle{fancyplain}\n"
465 "\\newcommand{\\clearemptydoublepage}{%\n"
466 " \\newpage{\\pagestyle{empty}\\cleardoublepage}%\n"
468 if (!Config_getBool("COMPACT_LATEX"))
469 t << "\\renewcommand{\\chaptermark}[1]{%\n"
470 " \\markboth{#1}{}%\n"
472 t << "\\renewcommand{\\sectionmark}[1]{%\n"
473 " \\markright{\\thesection\\ #1}%\n"
476 //t << "\\lhead[\\fancyplain{}{\\bfseries\\thepage}]{%\n"
477 // " \\fancyplain{}{\\bfseries\\rightmark}%\n"
479 //t << "\\rhead[\\fancyplain{}{\\bfseries\\leftmark}]{%\n"
480 // " \\fancyplain{}{\\bfseries\\thepage}%\n"
482 //t << "\\rfoot[\\fancyplain{}{\\bfseries\\scriptsize%\n ";
483 t << "\\fancyhead[LE]{\\fancyplain{}{\\bfseries\\thepage}}\n";
484 t << "\\fancyhead[CE]{\\fancyplain{}{}}\n";
485 t << "\\fancyhead[RE]{\\fancyplain{}{\\bfseries\\leftmark}}\n";
486 t << "\\fancyhead[LO]{\\fancyplain{}{\\bfseries\\rightmark}}\n";
487 t << "\\fancyhead[CO]{\\fancyplain{}{}}\n";
488 t << "\\fancyhead[RO]{\\fancyplain{}{\\bfseries\\thepage}}\n";
490 t << "\\fancyfoot[LE]{\\fancyplain{}{}}\n";
491 t << "\\fancyfoot[CE]{\\fancyplain{}{}}\n";
492 t << "\\fancyfoot[RE]{\\fancyplain{}{\\bfseries\\scriptsize ";
495 static void writeDefaultStyleSheetPart2(FTextStream &t)
498 t << "\\fancyfoot[LO]{\\fancyplain{}{\\bfseries\\scriptsize ";
499 //t << "\\lfoot[]{\\fancyplain{}{\\bfseries\\scriptsize%\n ";
503 static void writeDefaultStyleSheetPart3(FTextStream &t)
505 //static bool latexSourceCode = Config_getBool("LATEX_SOURCE_CODE");
507 //t << "\\cfoot{}\n\n";
508 t << "\\fancyfoot[CO]{\\fancyplain{}{}}\n";
509 t << "\\fancyfoot[RO]{\\fancyplain{}{}}\n";
511 t << "%---------- Internal commands used in this style file ----------------\n\n";
513 t << "\\newcommand\\tabfill[1]{%\n";
514 t << " \\dimen@\\linewidth%\n";
515 t << " \\advance\\dimen@\\@totalleftmargin%\n";
516 t << " \\advance\\dimen@-\\dimen\\@curtab%\n";
517 t << " \\parbox[t]\\dimen@{\\raggedright #1\\ifhmode\\strut\\fi}%\n";
520 t << "\\newcommand{\\ensurespace}[1]{%\n";
521 t << " \\begingroup\n";
522 t << " \\setlength{\\dimen@}{#1}%\n";
523 t << " \\vskip\\z@\\@plus\\dimen@\n";
524 t << " \\penalty -100\\vskip\\z@\\@plus -\\dimen@\n";
525 t << " \\vskip\\dimen@\n";
526 t << " \\penalty 9999%\n";
527 t << " \\vskip -\\dimen@\n";
528 t << " \\vskip\\z@skip % hide the previous |\\vskip| from |\\addvspace|\n";
529 t << " \\endgroup\n";
532 t << "% Generic environment used by all paragraph-based environments defined\n"
533 "% below. Note that the command \\title{...} needs to be defined inside\n"
534 "% those environments!\n"
535 "\\newenvironment{DoxyDesc}[1]{%\n"
537 " \\ensurespace{4\\baselineskip}%\n"
538 " \\begin{list}{}%\n"
540 " \\settowidth{\\labelwidth}{40pt}%\n"
541 " \\setlength{\\leftmargin}{\\labelwidth}%\n"
542 " \\setlength{\\parsep}{0pt}%\n"
543 " \\setlength{\\itemsep}{-4pt}%\n"
544 " \\renewcommand{\\makelabel}{\\entrylabel}%\n"
550 t << "%---------- Commands used by doxygen LaTeX output generator ----------\n\n";
551 t << "% Used by <pre> ... </pre>\n"
552 "\\newenvironment{DoxyPre}{%\n"
559 t << "% Used by @code ... @endcode\n"
560 "\\newenvironment{DoxyCode}{%\n";
561 //if (latexSourceCode)
563 t << "\n\n\\begin{scriptsize}\\begin{alltt}%" << endl;
567 // t << " \\footnotesize%\n"
571 //if (latexSourceCode)
573 t << "\\end{alltt}\\end{scriptsize}%" << endl;
577 // t << " \\endverbatim%\n"
578 // " \\normalsize%\n";
581 t << "% Used by @example, @include, @includelineno and @dontinclude\n"
582 "\\newenvironment{DoxyCodeInclude}{%\n"
587 t << "% Used by @verbatim ... @endverbatim\n"
588 "\\newenvironment{DoxyVerb}{%\n"
595 t << "% Used by @verbinclude\n"
596 "\\newenvironment{DoxyVerbInclude}{%\n"
601 t << "% Used by numbered lists (using '-#' or <ol> ... </ol>)\n"
602 "\\newenvironment{DoxyEnumerate}{%\n"
607 t << "% Used by bullet lists (using '-', @li, @arg, or <ul> ... </ul>)\n"
608 "\\newenvironment{DoxyItemize}{%\n"
613 t << "% Used by description lists (using <dl> ... </dl>)\n"
614 "\\newenvironment{DoxyDescription}{%\n"
617 " \\enddescription%\n"
619 t << "% Used by @image, @dotfile, and @dot ... @enddot\n"
620 "% (only if caption is specified)\n"
621 "\\newenvironment{DoxyImage}{%\n"
622 " \\begin{figure}[H]%\n"
623 " \\begin{center}%\n"
628 t << "% Used by @image, @dotfile, @dot ... @enddot, and @msc ... @endmsc\n"
629 "% (only if no caption is specified)\n"
630 "\\newenvironment{DoxyImageNoCaption}{%\n"
633 t << "% Used by @attention\n"
634 "\\newenvironment{DoxyAttention}[1]{%\n"
635 " \\begin{DoxyDesc}{#1}%\n"
637 " \\end{DoxyDesc}%\n"
639 t << "% Used by @author and @authors\n"
640 "\\newenvironment{DoxyAuthor}[1]{%\n"
641 " \\begin{DoxyDesc}{#1}%\n"
643 " \\end{DoxyDesc}%\n"
645 t << "% Used by @date\n"
646 "\\newenvironment{DoxyDate}[1]{%\n"
647 " \\begin{DoxyDesc}{#1}%\n"
649 " \\end{DoxyDesc}%\n"
651 t << "% Used by @invariant\n"
652 "\\newenvironment{DoxyInvariant}[1]{%\n"
653 " \\begin{DoxyDesc}{#1}%\n"
655 " \\end{DoxyDesc}%\n"
657 t << "% Used by @note\n"
658 "\\newenvironment{DoxyNote}[1]{%\n"
659 " \\begin{DoxyDesc}{#1}%\n"
661 " \\end{DoxyDesc}%\n"
663 t << "% Used by @post\n"
664 "\\newenvironment{DoxyPostcond}[1]{%\n"
665 " \\begin{DoxyDesc}{#1}%\n"
667 " \\end{DoxyDesc}%\n"
669 t << "% Used by @pre\n"
670 "\\newenvironment{DoxyPrecond}[1]{%\n"
671 " \\begin{DoxyDesc}{#1}%\n"
673 " \\end{DoxyDesc}%\n"
675 t << "% Used by @copyright\n"
676 "\\newenvironment{DoxyCopyright}[1]{%\n"
677 " \\begin{DoxyDesc}{#1}%\n"
679 " \\end{DoxyDesc}%\n"
681 t << "% Used by @remark\n"
682 "\\newenvironment{DoxyRemark}[1]{%\n"
683 " \\begin{DoxyDesc}{#1}%\n"
685 " \\end{DoxyDesc}%\n"
687 t << "% Used by @return\n"
688 "\\newenvironment{DoxyReturn}[1]{%\n"
689 " \\begin{DoxyDesc}{#1}%\n"
691 " \\end{DoxyDesc}%\n"
693 t << "% Used by @since\n"
694 "\\newenvironment{DoxySince}[1]{%\n"
695 " \\begin{DoxyDesc}{#1}%\n"
697 " \\end{DoxyDesc}%\n"
699 t << "% Used by @see\n"
700 "\\newenvironment{DoxySeeAlso}[1]{%\n"
701 " \\begin{DoxyDesc}{#1}%\n"
703 " \\end{DoxyDesc}%\n"
705 t << "% Used by @version\n"
706 "\\newenvironment{DoxyVersion}[1]{%\n"
707 " \\begin{DoxyDesc}{#1}%\n"
709 " \\end{DoxyDesc}%\n"
711 t << "% Used by @warning\n"
712 "\\newenvironment{DoxyWarning}[1]{%\n"
713 " \\begin{DoxyDesc}{#1}%\n"
715 " \\end{DoxyDesc}%\n"
717 t << "% Used by @internal\n"
718 "\\newenvironment{DoxyInternal}[1]{%\n"
719 " \\paragraph*{#1}%\n"
722 t << "% Used by @par and @paragraph\n"
723 "\\newenvironment{DoxyParagraph}[1]{%\n"
724 " \\begin{list}{}%\n"
726 " \\settowidth{\\labelwidth}{40pt}%\n"
727 " \\setlength{\\leftmargin}{\\labelwidth}%\n"
728 " \\setlength{\\parsep}{0pt}%\n"
729 " \\setlength{\\itemsep}{-4pt}%\n"
730 " \\renewcommand{\\makelabel}{\\entrylabel}%\n"
736 t << "% Used by parameter lists\n"
737 "\\newenvironment{DoxyParams}[2][]{%\n"
738 " \\begin{DoxyDesc}{#2}%\n"
739 //" \\begin{description}%\n"
740 " \\item[] \\hspace{\\fill} \\vspace{-40pt}%\n"
741 //" \\definecolor{tableShade}{HTML}{F8F8F8}%\n"
742 //" \\rowcolors{1}{white}{tableShade}%\n"
743 //" \\arrayrulecolor{gray}%\n"
744 " \\settowidth{\\labelwidth}{40pt}%\n"
745 //" \\setlength{\\LTleft}{\\labelwidth}%\n"
746 " \\setlength{\\LTleft}{0pt}%\n"
747 " \\setlength{\\tabcolsep}{0.01\\textwidth}%\n"
748 " \\ifthenelse{\\equal{#1}{}}%\n" // default: name, docs columns
749 " {\\begin{longtable}{|>{\\raggedleft\\hspace{0pt}}p{0.15\\textwidth}|%\n"
750 " p{0.815\\textwidth}|}}%\n"
751 " {\\ifthenelse{\\equal{#1}{1}}%\n" // inout, name, docs columns, or type, name, docs columns
752 " {\\begin{longtable}{|>{\\centering}p{0.10\\textwidth}|%\n"
753 " >{\\raggedleft\\hspace{0pt}}p{0.15\\textwidth}|%\n"
754 " p{0.685\\textwidth}|}}%\n"
755 " {\\begin{longtable}{|>{\\centering}p{0.10\\textwidth}|%\n" // inout, type, name, docs columns
756 " >{\\centering\\hspace{0pt}}p{0.15\\textwidth}|%\n"
757 " >{\\raggedleft\\hspace{0pt}}p{0.15\\textwidth}|%\n"
758 " p{0.515\\textwidth}|}}%\n"
761 " \\end{longtable}%\n"
762 //" \\end{description}%\n"
763 " \\end{DoxyDesc}%\n"
765 t << "% Used for fields of simple structs\n"
766 "\\newenvironment{DoxyFields}[1]{%\n"
767 " \\begin{DoxyDesc}{#1}%\n"
768 " \\item[] \\hspace{\\fill} \\vspace{-40pt}%\n"
769 " \\settowidth{\\labelwidth}{40pt}%\n"
770 " \\setlength{\\LTleft}{0pt}%\n"
771 " \\setlength{\\tabcolsep}{0.01\\textwidth}%\n"
772 " \\begin{longtable}{|>{\\raggedleft\\hspace{0pt}}p{0.15\\textwidth}|%\n"
773 " p{0.15\\textwidth}|%\n"
774 " p{0.635\\textwidth}|}%\n"
775 //"\\hline{\\sf\\textbf{Type}} & {\\sf\\textbf{Name}} & {\\sf\\textbf{Description}}\\endhead%\n"
778 " \\end{longtable}%\n"
779 //" \\end{description}%\n"
780 " \\end{DoxyDesc}%\n"
782 t << "% is used for parameters within a detailed function description\n"
783 "\\newenvironment{DoxyParamCaption}{%\n"
784 " \\renewcommand{\\item}[2][]{##1 {\\em ##2}}%\n"
787 t << "% Used by return value lists\n"
788 "\\newenvironment{DoxyRetVals}[1]{%\n"
789 " \\begin{DoxyDesc}{#1}%\n"
790 " \\begin{description}%\n"
791 " \\item[] \\hspace{\\fill} \\vspace{-25pt}%\n"
792 //" \\definecolor{tableShade}{HTML}{F8F8F8}%\n"
793 //" \\rowcolors{1}{white}{tableShade}%\n"
794 //" \\arrayrulecolor{gray}%\n"
795 " \\setlength{\\tabcolsep}{0.01\\textwidth}%\n"
796 " \\begin{longtable}{|>{\\raggedleft\\hspace{0pt}}p{0.25\\textwidth}|%\n"
797 " p{0.77\\textwidth}|}%\n"
800 " \\end{longtable}%\n"
801 " \\end{description}%\n"
802 " \\end{DoxyDesc}%\n"
804 t << "% Used by exception lists\n"
805 "\\newenvironment{DoxyExceptions}[1]{%\n"
806 " \\begin{DoxyDesc}{#1}%\n"
807 " \\begin{description}%\n"
808 " \\item[] \\hspace{\\fill} \\vspace{-25pt}%\n"
809 " \\definecolor{tableShade}{HTML}{F8F8F8}%\n"
810 " \\rowcolors{1}{white}{tableShade}%\n"
811 " \\arrayrulecolor{gray}%\n"
812 " \\setlength{\\tabcolsep}{0.01\\textwidth}%\n"
813 " \\begin{longtable}{|>{\\raggedleft\\hspace{0pt}}p{0.25\\textwidth}|%\n"
814 " p{0.77\\textwidth}|}%\n"
817 " \\end{longtable}%\n"
818 " \\end{description}%\n"
819 " \\end{DoxyDesc}%\n"
821 t << "% Used by template parameter lists\n"
822 "\\newenvironment{DoxyTemplParams}[1]{%\n"
823 " \\begin{DoxyDesc}{#1}%\n"
824 " \\begin{description}%\n"
825 " \\item[] \\hspace{\\fill} \\vspace{-25pt}%\n"
826 " \\definecolor{tableShade}{HTML}{F8F8F8}%\n"
827 " \\rowcolors{1}{white}{tableShade}%\n"
828 " \\arrayrulecolor{gray}%\n"
829 " \\setlength{\\tabcolsep}{0.01\\textwidth}%\n"
830 " \\begin{longtable}{|>{\\raggedleft\\hspace{0pt}}p{0.25\\textwidth}|%\n"
831 " p{0.77\\textwidth}|}%\n"
834 " \\end{longtable}%\n"
835 " \\end{description}%\n"
836 " \\end{DoxyDesc}%\n"
838 t << "\\newcommand{\\doxyref}[3]{\\textbf{#1} (\\textnormal{#2}\\,\\pageref{#3})}\n";
839 t << "\\newenvironment{DoxyCompactList}\n";
840 t << "{\\begin{list}{}{\n";
841 t << " \\setlength{\\leftmargin}{0.5cm}\n";
842 t << " \\setlength{\\itemsep}{0pt}\n";
843 t << " \\setlength{\\parsep}{0pt}\n";
844 t << " \\setlength{\\topsep}{0pt}\n";
845 t << " \\renewcommand{\\makelabel}{\\hfill}}}\n";
846 t << "{\\end{list}}\n";
847 t << "\\newenvironment{DoxyCompactItemize}\n";
849 t << " \\begin{itemize}\n";
850 t << " \\setlength{\\itemsep}{-3pt}\n";
851 t << " \\setlength{\\parsep}{0pt}\n";
852 t << " \\setlength{\\topsep}{0pt}\n";
853 t << " \\setlength{\\partopsep}{0pt}\n";
855 t << "{\\end{itemize}}\n";
856 t << "\\newcommand{\\PBS}[1]{\\let\\temp=\\\\#1\\let\\\\=\\temp}\n";
857 t << "\\newlength{\\tmplength}\n";
858 t << "\\newenvironment{TabularC}[1]\n";
860 t << "\\setlength{\\tmplength}\n";
861 t << " {\\linewidth/(#1)-\\tabcolsep*2-\\arrayrulewidth*(#1+1)/(#1)}\n";
862 t << " \\par\\begin{xtabular*}{\\linewidth}\n";
863 t << " {*{#1}{|>{\\PBS\\raggedright\\hspace{0pt}}p{\\the\\tmplength}}|}\n";
865 t << "{\\end{xtabular*}\\par}\n";
866 t << "\\newcommand{\\entrylabel}[1]{\n";
867 t << " {\\parbox[b]{\\labelwidth-4pt}{\\makebox[0pt][l]{%\n";
868 t << " \\usefont{OT1}{phv}{bc}{n}\\color{darkgray}#1}\\vspace{1.5\\baselineskip}}}}\n";
869 t << "\\newenvironment{Desc}\n";
870 t << "{\\begin{list}{}\n";
872 t << " \\settowidth{\\labelwidth}{40pt}\n";
873 t << " \\setlength{\\leftmargin}{\\labelwidth}\n";
874 t << " \\setlength{\\parsep}{0pt}\n";
875 t << " \\setlength{\\itemsep}{-4pt}\n";
876 t << " \\renewcommand{\\makelabel}{\\entrylabel}\n";
879 t << "{\\end{list}}\n";
881 t << "\\newsavebox{\\xrefbox}\n";
882 t << "\\newlength{\\xreflength}\n";
883 t << "\\newcommand{\\xreflabel}[1]{%\n";
884 t << " \\sbox{\\xrefbox}{#1}%\n";
885 t << " \\setlength{\\xreflength}{\\wd\\xrefbox}%\n";
886 t << " \\ifthenelse{\\xreflength>\\labelwidth}{%\n";
887 t << " \\begin{minipage}{\\textwidth}%\n";
888 t << " \\setlength{\\parindent}{0pt}%\n";
889 t << " \\hangindent=15pt\\bfseries #1\\vspace{1.2\\itemsep}%\n";
890 t << " \\end{minipage}%\n";
892 t << " \\parbox[b]{\\labelwidth}{\\makebox[0pt][l]{\\textbf{#1}}}%\n";
894 t << "\\newenvironment{DoxyRefList}{%\n";
895 t << " \\begin{list}{}{%\n";
896 t << " \\setlength{\\labelwidth}{10pt}%\n";
897 t << " \\setlength{\\leftmargin}{\\labelwidth}%\n";
898 t << " \\addtolength{\\leftmargin}{\\labelsep}%\n";
899 t << " \\renewcommand{\\makelabel}{\\xreflabel}%\n";
902 t << "{\\end{list}}\n";
903 t << "\\newenvironment{DoxyRefDesc}[1]\n";
904 t << "{\\begin{list}{}{%\n";
905 t << " \\renewcommand\\makelabel[1]{\\textbf{##1}}\n";
906 t << " \\settowidth\\labelwidth{\\makelabel{#1}}\n";
907 t << " \\setlength\\leftmargin{\\labelwidth+\\labelsep}}}\n";
908 t << "{\\end{list}}\n";
909 t << "\\newenvironment{Indent}\n";
910 t << " {\\begin{list}{}{\\setlength{\\leftmargin}{0.5cm}}\n";
911 t << " \\item[]\\ignorespaces}\n";
912 t << " {\\unskip\\end{list}}\n";
914 t << "\\setlength{\\parindent}{0cm}\n";
915 t << "\\setlength{\\parskip}{0.2cm}\n";
916 t << "\\addtocounter{secnumdepth}{2}\n";
917 // \sloppy should not be used, see bug 563698
919 t << "\\usepackage[T1]{fontenc}\n";
920 t << "\\makeatletter\n";
921 t << "\\renewcommand{\\paragraph}{\\@startsection{paragraph}{4}{0ex}%\n";
924 t << " {\\usefont{OT1}{phv}{bc}{n}\\color{darkgray}}}\n";
925 t << "\\renewcommand{\\subparagraph}{\\@startsection{subparagraph}{5}{0ex}%\n";
928 t << " {\\usefont{OT1}{phv}{bc}{n}\\color{darkgray}}}\n";
929 t << "\\makeatother\n";
930 t << "\\allsectionsfont{\\usefont{OT1}{phv}{bc}{n}\\selectfont\\color{darkgray}}\n";
931 t << "\\stepcounter{secnumdepth}\n";
932 t << "\\stepcounter{tocdepth}\n";
933 t << "\\definecolor{comment}{rgb}{0.5,0.0,0.0}\n";
934 t << "\\definecolor{keyword}{rgb}{0.0,0.5,0.0}\n";
935 t << "\\definecolor{keywordtype}{rgb}{0.38,0.25,0.125}\n";
936 t << "\\definecolor{keywordflow}{rgb}{0.88,0.5,0.0}\n";
937 t << "\\definecolor{preprocessor}{rgb}{0.5,0.38,0.125}\n";
938 t << "\\definecolor{stringliteral}{rgb}{0.0,0.125,0.25}\n";
939 t << "\\definecolor{charliteral}{rgb}{0.0,0.5,0.5}\n";
940 t << "\\definecolor{vhdldigit}{rgb}{1.0,0.0,1.0}\n";
941 t << "\\definecolor{vhdlkeyword}{rgb}{0.43,0.0,0.43}\n";
942 t << "\\definecolor{vhdllogic}{rgb}{1.0,0.0,0.0}\n";
943 t << "\\definecolor{vhdlchar}{rgb}{0.0,0.0,0.0}\n";
946 static void writeDefaultFooter(FTextStream &t)
948 Doxygen::citeDict->writeLatexBibliography(t);
949 t << "\\addcontentsline{toc}{part}{" << theTranslator->trRTFGeneralIndex() << "}\n";
950 t << "\\printindex\n";
951 t << "\\end{document}\n";
954 void LatexGenerator::writeHeaderFile(QFile &f)
957 writeDefaultHeaderPart1(t);
958 t << "Your title here";
959 writeDefaultHeaderPart2(t);
961 writeDefaultHeaderPart3(t);
964 void LatexGenerator::writeFooterFile(QFile &f)
967 writeDefaultFooter(t);
970 void LatexGenerator::writeStyleSheetFile(QFile &f)
974 writeDefaultStyleSheetPart1(t);
975 QCString &projectName = Config_getString("PROJECT_NAME");
977 t << theTranslator->trGeneratedAt( dateToString(TRUE), projectName );
979 //t << " " << theTranslator->trWrittenBy() << " ";
980 //t << "Dimitri van Heesch \\copyright~1997-2012";
981 writeDefaultStyleSheetPart2(t);
982 t << theTranslator->trGeneratedAt( dateToString(TRUE), projectName );
984 //t << " << theTranslator->trWrittenBy() << " ";
985 //t << "Dimitri van Heesch \\copyright~1997-2012";
986 writeDefaultStyleSheetPart3(t);
989 void LatexGenerator::startFile(const char *name,const char *,const char *)
992 setEncoding(Config_getString("LATEX_OUTPUT_ENCODING"));
994 QCString fileName=name;
995 relPath = relativePathToRoot(fileName);
996 sourceFileName = stripPath(fileName);
997 if (fileName.right(4)!=".tex" && fileName.right(4)!=".sty") fileName+=".tex";
998 startPlainFile(fileName);
1001 void LatexGenerator::endFile()
1004 sourceFileName.resize(0);
1007 //void LatexGenerator::writeIndex()
1009 // startFile("refman.tex");
1012 void LatexGenerator::startProjectNumber()
1014 t << "\\\\[1ex]\\large ";
1017 void LatexGenerator::startIndexSection(IndexSections is)
1019 bool &compactLatex = Config_getBool("COMPACT_LATEX");
1020 QCString &latexHeader = Config_getString("LATEX_HEADER");
1023 case isTitlePageStart:
1025 if (latexHeader.isEmpty())
1027 writeDefaultHeaderPart1(t);
1031 QCString header = fileToString(latexHeader);
1032 t << substituteKeywords(header,0,
1033 Config_getString("PROJECT_NAME"),
1034 Config_getString("PROJECT_NUMBER"),
1035 Config_getString("PROJECT_BRIEF"));
1039 case isTitlePageAuthor:
1040 if (latexHeader.isEmpty())
1042 writeDefaultHeaderPart2(t);
1046 if (compactLatex) t << "\\section"; else t << "\\chapter";
1047 t << "{"; //Introduction}\n"
1049 //case isPackageIndex:
1050 // if (compactLatex) t << "\\section"; else t << "\\chapter";
1051 // t << "{"; //Package Index}\n"
1054 if (compactLatex) t << "\\section"; else t << "\\chapter";
1055 t << "{"; //Module Index}\n"
1058 if (compactLatex) t << "\\section"; else t << "\\chapter";
1059 t << "{"; //Directory Index}\n"
1061 case isNamespaceIndex:
1062 if (compactLatex) t << "\\section"; else t << "\\chapter";
1063 t << "{"; //Namespace Index}\"
1065 case isClassHierarchyIndex:
1066 if (compactLatex) t << "\\section"; else t << "\\chapter";
1067 t << "{"; //Hierarchical Index}\n"
1069 case isCompoundIndex:
1070 if (compactLatex) t << "\\section"; else t << "\\chapter";
1071 t << "{"; //Annotated Compound Index}\n"
1074 if (compactLatex) t << "\\section"; else t << "\\chapter";
1075 t << "{"; //Annotated File Index}\n"
1078 if (compactLatex) t << "\\section"; else t << "\\chapter";
1079 t << "{"; //Annotated Page Index}\n"
1081 case isModuleDocumentation:
1083 GroupSDict::Iterator gli(*Doxygen::groupSDict);
1086 for (gli.toFirst();(gd=gli.current()) && !found;++gli)
1088 if (!gd->isReference())
1090 if (compactLatex) t << "\\section"; else t << "\\chapter";
1091 t << "{"; //Module Documentation}\n";
1097 case isDirDocumentation:
1099 SDict<DirDef>::Iterator dli(*Doxygen::directories);
1102 for (dli.toFirst();(dd=dli.current()) && !found;++dli)
1104 if (dd->isLinkableInProject())
1106 if (compactLatex) t << "\\section"; else t << "\\chapter";
1107 t << "{"; //Module Documentation}\n";
1113 case isNamespaceDocumentation:
1115 NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
1118 for (nli.toFirst();(nd=nli.current()) && !found;++nli)
1120 if (nd->isLinkableInProject())
1122 if (compactLatex) t << "\\section"; else t << "\\chapter";
1123 t << "{"; // Namespace Documentation}\n":
1129 case isClassDocumentation:
1131 ClassSDict::Iterator cli(*Doxygen::classSDict);
1134 for (cli.toFirst();(cd=cli.current()) && !found;++cli)
1136 if (cd->isLinkableInProject() &&
1137 cd->templateMaster()==0 &&
1138 !cd->isEmbeddedInOuterScope()
1141 if (compactLatex) t << "\\section"; else t << "\\chapter";
1142 t << "{"; //Compound Documentation}\n";
1148 case isFileDocumentation:
1151 FileName *fn=Doxygen::inputNameList->first();
1154 FileDef *fd=fn->first();
1157 if (fd->isLinkableInProject())
1161 if (compactLatex) t << "\\section"; else t << "\\chapter";
1162 t << "{"; //File Documentation}\n";
1169 fn=Doxygen::inputNameList->next();
1173 case isExampleDocumentation:
1175 if (compactLatex) t << "\\section"; else t << "\\chapter";
1176 t << "{"; //Example Documentation}\n";
1179 case isPageDocumentation:
1181 if (compactLatex) t << "\\section"; else t << "\\chapter";
1182 t << "{"; //Page Documentation}\n";
1185 case isPageDocumentation2:
1192 void LatexGenerator::endIndexSection(IndexSections is)
1194 //static bool compactLatex = Config_getBool("COMPACT_LATEX");
1195 static bool sourceBrowser = Config_getBool("SOURCE_BROWSER");
1196 static QCString latexHeader = Config_getString("LATEX_HEADER");
1197 static QCString latexFooter = Config_getString("LATEX_FOOTER");
1200 case isTitlePageStart:
1202 case isTitlePageAuthor:
1203 if (latexHeader.isEmpty())
1205 writeDefaultHeaderPart3(t);
1210 //QCString indexName=Config_getBool("GENERATE_TREEVIEW")?"main":"index";
1211 QCString indexName="index";
1212 t << "}\n\\label{index}";
1213 if (Config_getBool("PDF_HYPERLINKS")) t << "\\hypertarget{index}{}";
1214 t << "\\input{" << indexName << "}\n";
1218 t << "}\n\\input{modules}\n";
1221 t << "}\n\\input{dirs}\n";
1223 case isNamespaceIndex:
1224 t << "}\n\\input{namespaces}\n";
1226 case isClassHierarchyIndex:
1227 t << "}\n\\input{hierarchy}\n";
1229 case isCompoundIndex:
1230 t << "}\n\\input{annotated}\n";
1233 t << "}\n\\input{files}\n";
1236 t << "}\n\\input{pages}\n";
1238 case isModuleDocumentation:
1240 GroupSDict::Iterator gli(*Doxygen::groupSDict);
1243 for (gli.toFirst();(gd=gli.current()) && !found;++gli)
1245 if (!gd->isReference())
1247 t << "}\n\\input{" << gd->getOutputFileBase() << "}\n";
1251 for (;(gd=gli.current());++gli)
1253 if (!gd->isReference())
1255 //if (compactLatex) t << "\\input"; else t << "\\include";
1257 t << "{" << gd->getOutputFileBase() << "}\n";
1262 case isDirDocumentation:
1264 SDict<DirDef>::Iterator dli(*Doxygen::directories);
1267 for (dli.toFirst();(dd=dli.current()) && !found;++dli)
1269 if (dd->isLinkableInProject())
1271 t << "}\n\\input{" << dd->getOutputFileBase() << "}\n";
1275 for (;(dd=dli.current());++dli)
1277 if (dd->isLinkableInProject())
1279 //if (compactLatex) t << "\\input"; else t << "\\include";
1281 t << "{" << dd->getOutputFileBase() << "}\n";
1286 case isNamespaceDocumentation:
1288 NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
1291 for (nli.toFirst();(nd=nli.current()) && !found;++nli)
1293 if (nd->isLinkableInProject())
1295 t << "}\n\\input{" << nd->getOutputFileBase() << "}\n";
1299 while ((nd=nli.current()))
1301 if (nd->isLinkableInProject())
1303 //if (compactLatex) t << "\\input"; else t << "\\include";
1305 t << "{" << nd->getOutputFileBase() << "}\n";
1311 case isClassDocumentation:
1313 ClassSDict::Iterator cli(*Doxygen::classSDict);
1316 for (cli.toFirst();(cd=cli.current()) && !found;++cli)
1318 if (cd->isLinkableInProject() &&
1319 cd->templateMaster()==0 &&
1320 !cd->isEmbeddedInOuterScope()
1323 t << "}\n\\input{" << cd->getOutputFileBase() << "}\n";
1327 for (;(cd=cli.current());++cli)
1329 if (cd->isLinkableInProject() &&
1330 cd->templateMaster()==0 &&
1331 !cd->isEmbeddedInOuterScope()
1334 //if (compactLatex) t << "\\input"; else t << "\\include";
1336 t << "{" << cd->getOutputFileBase() << "}\n";
1341 case isFileDocumentation:
1344 FileName *fn=Doxygen::inputNameList->first();
1347 FileDef *fd=fn->first();
1350 if (fd->isLinkableInProject())
1354 t << "}\n\\input{" << fd->getOutputFileBase() << "}\n";
1355 if (sourceBrowser && m_prettyCode && fd->generateSourceFile())
1357 //t << "\\include{" << fd->getSourceFileBase() << "}\n";
1358 t << "\\input{" << fd->getSourceFileBase() << "}\n";
1364 //if (compactLatex) t << "\\input" ; else t << "\\include";
1366 t << "{" << fd->getOutputFileBase() << "}\n";
1367 if (sourceBrowser && m_prettyCode && fd->generateSourceFile())
1369 //t << "\\include{" << fd->getSourceFileBase() << "}\n";
1370 t << "\\input{" << fd->getSourceFileBase() << "}\n";
1376 fn=Doxygen::inputNameList->next();
1380 case isExampleDocumentation:
1383 PageSDict::Iterator pdi(*Doxygen::exampleSDict);
1384 PageDef *pd=pdi.toFirst();
1387 t << "\\input{" << pd->getOutputFileBase() << "}\n";
1389 for (++pdi;(pd=pdi.current());++pdi)
1391 //if (compactLatex) t << "\\input" ; else t << "\\include";
1393 t << "{" << pd->getOutputFileBase() << "}\n";
1397 case isPageDocumentation:
1401 PageSDict::Iterator pdi(*Doxygen::pageSDict);
1402 PageDef *pd=pdi.toFirst();
1404 for (pdi.toFirst();(pd=pdi.current());++pdi)
1406 if (!pd->getGroupDef() && !pd->isReference())
1408 if (compactLatex) t << "\\section"; else t << "\\chapter";
1409 t << "{" << pd->title();
1412 if (compactLatex || first) t << "\\input" ; else t << "\\include";
1413 t << "{" << pd->getOutputFileBase() << "}\n";
1420 case isPageDocumentation2:
1423 if (latexFooter.isEmpty())
1425 writeDefaultFooter(t);
1429 QCString footer = fileToString(latexFooter);
1430 t << substituteKeywords(footer,0,
1431 Config_getString("PROJECT_NAME"),
1432 Config_getString("PROJECT_NUMBER"),
1433 Config_getString("PROJECT_BRIEF"));
1439 void LatexGenerator::writePageLink(const char *name, bool /*first*/)
1441 //bool &compactLatex = Config_getBool("COMPACT_LATEX");
1442 // next is remove for bug615957
1443 //if (compactLatex || first) t << "\\input" ; else t << "\\include";
1445 t << "{" << name << "}\n";
1449 void LatexGenerator::writeStyleInfo(int part)
1455 //QCString pname=Config_getString("PROJECT_NAME").stripWhiteSpace();
1456 startPlainFile("doxygen.sty");
1457 writeDefaultStyleSheetPart1(t);
1466 writeDefaultStyleSheetPart2(t);
1471 writeDefaultStyleSheetPart3(t);
1478 void LatexGenerator::newParagraph()
1483 void LatexGenerator::startParagraph()
1488 void LatexGenerator::endParagraph()
1493 void LatexGenerator::writeString(const char *text)
1498 void LatexGenerator::startIndexItem(const char *ref,const char *fn)
1503 t << "\\contentsline{section}{";
1507 void LatexGenerator::endIndexItem(const char *ref,const char *fn)
1511 t << "}{\\pageref{" << fn << "}}{}" << endl;
1515 //void LatexGenerator::writeIndexFileItem(const char *,const char *text)
1517 // t << "\\item\\contentsline{section}{";
1519 // t << "}{\\pageref{" << text << "}}" << endl;
1523 void LatexGenerator::startHtmlLink(const char *url)
1525 if (Config_getBool("PDF_HYPERLINKS"))
1534 void LatexGenerator::endHtmlLink()
1539 //void LatexGenerator::writeMailLink(const char *url)
1541 // if (Config_getBool("PDF_HYPERLINKS"))
1543 // t << "\\href{mailto:";
1552 void LatexGenerator::writeStartAnnoItem(const char *,const char *,
1553 const char *path,const char *name)
1555 t << "\\item\\contentsline{section}{\\bf ";
1556 if (path) docify(path);
1561 void LatexGenerator::writeEndAnnoItem(const char *name)
1563 t << "}{\\pageref{" << name << "}}{}" << endl;
1566 void LatexGenerator::startIndexKey()
1568 t << "\\item\\contentsline{section}{";
1571 void LatexGenerator::endIndexKey()
1575 void LatexGenerator::startIndexValue(bool hasBrief)
1578 if (hasBrief) t << "\\\\*";
1581 void LatexGenerator::endIndexValue(const char *name,bool /*hasBrief*/)
1583 //if (hasBrief) t << ")";
1584 t << "}{\\pageref{" << name << "}}{}" << endl;
1587 //void LatexGenerator::writeClassLink(const char *,const char *,
1588 // const char *,const char *name)
1595 void LatexGenerator::startTextLink(const char *f,const char *anchor)
1597 if (!disableLinks && Config_getBool("PDF_HYPERLINKS"))
1599 t << "\\hyperlink{";
1600 if (f) t << stripPath(f);
1601 if (anchor) t << "_" << anchor;
1610 void LatexGenerator::endTextLink()
1615 void LatexGenerator::writeObjectLink(const char *ref, const char *f,
1616 const char *anchor, const char *text)
1618 if (!disableLinks && !ref && Config_getBool("PDF_HYPERLINKS"))
1620 t << "\\hyperlink{";
1621 if (f) t << stripPath(f);
1622 if (f && anchor) t << "_";
1623 if (anchor) t << anchor;
1636 void LatexGenerator::startPageRef()
1638 t << " \\doxyref{}{";
1641 void LatexGenerator::endPageRef(const char *clname, const char *anchor)
1644 if (clname) t << clname;
1645 if (anchor) t << "_" << anchor;
1649 void LatexGenerator::writeCodeLink(const char *ref,const char *f,
1650 const char *anchor,const char *name,
1653 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1654 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
1655 int l = strlen(name);
1661 if (/*m_prettyCode &&*/ !disableLinks && !ref && usePDFLatex && pdfHyperlinks)
1663 t << "\\hyperlink{";
1664 if (f) t << stripPath(f);
1665 if (f && anchor) t << "_";
1666 if (anchor) t << anchor;
1678 void LatexGenerator::startTitleHead(const char *fileName)
1680 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1681 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
1682 if (usePDFLatex && pdfHyperlinks && fileName)
1684 t << "\\hypertarget{" << stripPath(fileName) << "}{";
1686 if (Config_getBool("COMPACT_LATEX"))
1688 t << "\\subsection{";
1696 void LatexGenerator::endTitleHead(const char *fileName,const char *name)
1698 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1699 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
1703 t << "\\label{" << fileName << "}\\index{";
1704 escapeLabelName(name);
1706 escapeMakeIndexChars(name);
1709 if (usePDFLatex && pdfHyperlinks && fileName)
1715 void LatexGenerator::startTitle()
1717 if (Config_getBool("COMPACT_LATEX"))
1719 t << "\\subsection{";
1727 void LatexGenerator::startGroupHeader(int extraIndentLevel)
1729 if (Config_getBool("COMPACT_LATEX"))
1734 if (extraIndentLevel==3)
1736 t << "\\subparagraph*{";
1738 else if (extraIndentLevel==2)
1740 t << "\\paragraph{";
1742 else if (extraIndentLevel==1)
1744 t << "\\subsubsection{";
1746 else // extraIndentLevel==0
1748 t << "\\subsection{";
1753 void LatexGenerator::endGroupHeader(int)
1759 void LatexGenerator::startMemberHeader(const char *)
1761 if (Config_getBool("COMPACT_LATEX"))
1763 t << "\\subsubsection*{";
1767 t << "\\subsection*{";
1772 void LatexGenerator::endMemberHeader()
1778 void LatexGenerator::startMemberDoc(const char *clname,
1779 const char *memname,
1784 if (memname && memname[0]!='@')
1789 escapeLabelName(clname);
1791 escapeMakeIndexChars(clname);
1794 escapeLabelName(memname);
1796 escapeMakeIndexChars(memname);
1800 escapeLabelName(memname);
1802 escapeMakeIndexChars(memname);
1806 t << "!" << clname << "@{";
1812 static const char *levelLab[] = { "subsubsection","paragraph","subparagraph", "subparagraph" };
1813 static bool compactLatex = Config_getBool("COMPACT_LATEX");
1815 if (showInline) level+=2;
1816 if (compactLatex) level++;
1817 t << "\\" << levelLab[level];
1819 //if (Config_getBool("PDF_HYPERLINKS") && memname)
1822 // escapeMakeIndexChars(this,t,memname);
1826 escapeMakeIndexChars(title);
1828 t << "{\\setlength{\\rightskip}{0pt plus 5cm}";
1832 void LatexGenerator::endMemberDoc(bool)
1836 //if (Config_getBool("COMPACT_LATEX")) t << "\\hfill";
1839 void LatexGenerator::startDoxyAnchor(const char *fName,const char *,
1840 const char *anchor, const char *,
1843 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1844 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
1845 if (usePDFLatex && pdfHyperlinks)
1847 t << "\\hypertarget{";
1848 if (fName) t << stripPath(fName);
1849 if (anchor) t << "_" << anchor;
1854 void LatexGenerator::endDoxyAnchor(const char *fName,const char *anchor)
1856 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1857 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
1858 if (usePDFLatex && pdfHyperlinks)
1863 if (fName) t << fName;
1864 if (anchor) t << "_" << anchor;
1868 void LatexGenerator::writeAnchor(const char *fName,const char *name)
1870 //printf("LatexGenerator::writeAnchor(%s,%s)\n",fName,name);
1871 t << "\\label{" << name << "}" << endl;
1872 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1873 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
1874 if (usePDFLatex && pdfHyperlinks)
1878 t << "\\hypertarget{" << stripPath(fName) << "_" << name << "}{}" << endl;
1882 t << "\\hypertarget{" << name << "}{}" << endl;
1888 //void LatexGenerator::writeLatexLabel(const char *clName,const char *anchor)
1890 // writeDoxyAnchor(0,clName,anchor,0);
1893 void LatexGenerator::addIndexItem(const char *s1,const char *s2)
1898 escapeLabelName(s1);
1900 escapeMakeIndexChars(s1);
1905 escapeLabelName(s2);
1907 escapeMakeIndexChars(s2);
1915 void LatexGenerator::startSection(const char *lab,const char *,SectionInfo::SectionType type)
1917 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1918 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
1919 if (usePDFLatex && pdfHyperlinks)
1921 t << "\\hypertarget{" << stripPath(lab) << "}{}";
1924 if (Config_getBool("COMPACT_LATEX"))
1928 case SectionInfo::Page: t << "subsection"; break;
1929 case SectionInfo::Section: t << "subsubsection"; break;
1930 case SectionInfo::Subsection: t << "paragraph"; break;
1931 case SectionInfo::Subsubsection: t << "subparagraph"; break;
1932 case SectionInfo::Paragraph: t << "subparagraph"; break;
1933 default: ASSERT(0); break;
1941 case SectionInfo::Page: t << "section"; break;
1942 case SectionInfo::Section: t << "subsection"; break;
1943 case SectionInfo::Subsection: t << "subsubsection"; break;
1944 case SectionInfo::Subsubsection: t << "paragraph"; break;
1945 case SectionInfo::Paragraph: t << "subparagraph"; break;
1946 default: ASSERT(0); break;
1952 void LatexGenerator::endSection(const char *lab,SectionInfo::SectionType)
1954 t << "}\\label{" << lab << "}" << endl;
1958 void LatexGenerator::docify(const char *str)
1960 filterLatexString(t,str,insideTabbing,FALSE,FALSE);
1963 void LatexGenerator::codify(const char *str)
1970 int spacesToNextTabStop;
1971 static int tabSize = Config_getInt("TAB_SIZE");
1972 const int maxLineLen = 80;
1973 QCString result(4*maxLineLen+1); // worst case for 1 line of 4-byte chars
1979 case 0x0c: p++; // remove ^L
1981 case '\t': spacesToNextTabStop =
1982 tabSize - (col%tabSize);
1983 t << Doxygen::spaces.left(spacesToNextTabStop);
1984 col+=spacesToNextTabStop;
1987 case '\n': t << '\n'; col=0; p++;
1993 // helper macro to copy a single utf8 character, dealing with multibyte chars.
1994 #define COPYCHAR() do { \
1995 result[i++]=c; p++; \
1996 if (c<0) /* multibyte utf-8 character */ \
1998 /* 1xxx.xxxx: >=2 byte character */ \
2000 if (((uchar)c&0xE0)==0xE0) \
2002 /* 111x.xxxx: >=3 byte character */ \
2005 if (((uchar)c&0xF0)==0xF0) \
2007 /* 1111.xxxx: 4 byte character */ \
2014 // gather characters until we find whitespace or are at
2015 // the end of a line
2017 if (col>=maxLineLen) // force line break
2022 else // copy more characters
2024 while (col<maxLineLen && (c=*p) &&
2025 c!=0x0c && c!='\t' && c!='\n' && c!=' '
2030 if (col>=maxLineLen) // force line break
2036 result[i]=0; // add terminator
2039 filterLatexString(t,result,insideTabbing,TRUE);
2051 void LatexGenerator::writeChar(char c)
2059 void LatexGenerator::startClassDiagram()
2061 //if (Config_getBool("COMPACT_LATEX")) t << "\\subsubsection"; else t << "\\subsection";
2065 void LatexGenerator::endClassDiagram(const ClassDiagram &d,
2066 const char *fileName,const char *)
2068 d.writeFigure(t,dir,fileName);
2072 void LatexGenerator::startAnonTypeScope(int indent)
2076 t << "\\begin{tabbing}" << endl;
2077 t << "xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=\\kill" << endl;
2083 void LatexGenerator::endAnonTypeScope(int indent)
2087 t << endl << "\\end{tabbing}";
2088 insideTabbing=FALSE;
2093 void LatexGenerator::startMemberTemplateParams()
2095 if (templateMemberItem)
2097 t << "{\\footnotesize ";
2101 void LatexGenerator::endMemberTemplateParams(const char *,const char *)
2103 if (templateMemberItem)
2109 void LatexGenerator::startMemberItem(const char *,int annoType,const char *)
2111 //printf("LatexGenerator::startMemberItem(%d)\n",annType);
2114 t << "\\item " << endl;
2115 templateMemberItem = (annoType == 3);
2119 void LatexGenerator::endMemberItem()
2125 templateMemberItem = FALSE;
2129 void LatexGenerator::startMemberDescription(const char *,const char *)
2133 t << "\\begin{DoxyCompactList}\\small\\item\\em ";
2137 for (int i=0;i<m_indent+2;i++) t << "\\>";
2142 void LatexGenerator::endMemberDescription()
2146 //t << "\\item\\end{DoxyCompactList}";
2147 t << "\\end{DoxyCompactList}";
2156 void LatexGenerator::writeNonBreakableSpace(int)
2158 //printf("writeNonBreakbleSpace()\n");
2169 void LatexGenerator::startMemberList()
2173 t << "\\begin{DoxyCompactItemize}" << endl;
2177 void LatexGenerator::endMemberList()
2179 //printf("LatexGenerator::endMemberList(%d)\n",insideTabbing);
2182 t << "\\end{DoxyCompactItemize}" << endl;
2187 void LatexGenerator::startMemberGroupHeader(bool hasHeader)
2189 if (hasHeader) t << "\\begin{Indent}";
2191 // changed back to rev 756 due to bug 660501
2192 //if (Config_getBool("COMPACT_LATEX"))
2194 // t << "\\subparagraph*{";
2198 // t << "\\paragraph*{";
2202 void LatexGenerator::endMemberGroupHeader()
2204 // changed back to rev 756 due to bug 660501
2205 t << "}\\par" << endl;
2209 void LatexGenerator::startMemberGroupDocs()
2214 void LatexGenerator::endMemberGroupDocs()
2219 void LatexGenerator::startMemberGroup()
2223 void LatexGenerator::endMemberGroup(bool hasHeader)
2225 if (hasHeader)t << "\\end{Indent}";
2229 void LatexGenerator::startDotGraph()
2234 void LatexGenerator::endDotGraph(const DotClassGraph &g)
2236 g.writeGraph(t,EPS,Config_getString("LATEX_OUTPUT"),fileName,relPath);
2239 void LatexGenerator::startInclDepGraph()
2243 void LatexGenerator::endInclDepGraph(const DotInclDepGraph &g)
2245 g.writeGraph(t,EPS,Config_getString("LATEX_OUTPUT"),fileName,relPath);
2248 void LatexGenerator::startGroupCollaboration()
2252 void LatexGenerator::endGroupCollaboration(const DotGroupCollaboration &g)
2254 g.writeGraph(t,EPS,Config_getString("LATEX_OUTPUT"),fileName,relPath);
2257 void LatexGenerator::startCallGraph()
2261 void LatexGenerator::endCallGraph(const DotCallGraph &g)
2263 g.writeGraph(t,EPS,Config_getString("LATEX_OUTPUT"),fileName,relPath);
2266 void LatexGenerator::startDirDepGraph()
2270 void LatexGenerator::endDirDepGraph(const DotDirDeps &g)
2272 g.writeGraph(t,EPS,Config_getString("LATEX_OUTPUT"),fileName,relPath);
2275 void LatexGenerator::startDescription()
2277 t << "\\begin{description}" << endl;
2280 void LatexGenerator::endDescription()
2282 t << "\\end{description}" << endl;
2286 void LatexGenerator::startDescItem()
2292 void LatexGenerator::endDescItem()
2297 firstDescItem=FALSE;
2305 void LatexGenerator::startSimpleSect(SectionTypes,const char *file,
2306 const char *anchor,const char *title)
2308 t << "\\begin{Desc}\n\\item[";
2311 writeObjectLink(0,file,anchor,title);
2320 void LatexGenerator::endSimpleSect()
2322 t << "\\end{Desc}" << endl;
2325 void LatexGenerator::startParamList(ParamListTypes,const char *title)
2327 t << "\\begin{Desc}\n\\item[";
2332 void LatexGenerator::endParamList()
2334 t << "\\end{Desc}" << endl;
2337 void LatexGenerator::startParameterList(bool openBracket)
2339 /* start of ParameterType ParameterName list */
2340 if (openBracket) t << "(";
2341 t << endl << "\\begin{DoxyParamCaption}" << endl;
2344 void LatexGenerator::endParameterList()
2348 void LatexGenerator::startParameterType(bool first,const char *key)
2351 if (!first && key) t << key;
2354 void LatexGenerator::endParameterType()
2359 void LatexGenerator::startParameterName(bool /*oneArgOnly*/)
2364 void LatexGenerator::endParameterName(bool last,bool /* emptyList */,bool closeBracket)
2370 t << "\\end{DoxyParamCaption}" << endl;
2371 if (closeBracket) t << ")";
2376 void LatexGenerator::writeDoc(DocNode *n,Definition *ctx,MemberDef *)
2378 LatexDocVisitor *visitor =
2379 new LatexDocVisitor(t,*this,ctx?ctx->getDefFileExtension():QCString(""),insideTabbing);
2384 void LatexGenerator::startConstraintList(const char *header)
2386 t << "\\begin{Desc}\n\\item[";
2389 t << "\\begin{description}" << endl;
2392 void LatexGenerator::startConstraintParam()
2394 t << "\\item[{\\em ";
2397 void LatexGenerator::endConstraintParam()
2401 void LatexGenerator::startConstraintType()
2406 void LatexGenerator::endConstraintType()
2411 void LatexGenerator::startConstraintDocs()
2415 void LatexGenerator::endConstraintDocs()
2419 void LatexGenerator::endConstraintList()
2421 t << "\\end{description}" << endl;
2422 t << "\\end{Desc}" << endl;
2425 void LatexGenerator::escapeLabelName(const char *s)
2430 QCString result(strlen(s)+1); // worst case allocation
2436 case '%': t << "\\%"; break;
2437 // NOTE: adding a case here, means adding it to while below as well!
2440 // collect as long string as possible, before handing it to docify
2442 while ((c=*p) && c!='%')
2454 void LatexGenerator::escapeMakeIndexChars(const char *s)
2459 QCString result(strlen(s)+1); // worst case allocation
2465 case '"': t << "\"\""; break;
2466 case '@': t << "\"@"; break;
2467 case '[': t << "["; break;
2468 case ']': t << "]"; break;
2469 // NOTE: adding a case here, means adding it to while below as well!
2472 // collect as long string as possible, before handing it to docify
2474 while ((c=*p) && c!='"' && c!='@' && c!='[' && c!=']')
2486 void LatexGenerator::startCodeFragment()
2488 t << "\n\\begin{DoxyCode}\n";
2491 void LatexGenerator::endCodeFragment()
2493 t << "\\end{DoxyCode}\n";
2496 void LatexGenerator::writeLineNumber(const char *ref,const char *fileName,const char *anchor,int l)
2500 QCString lineNumber;
2501 lineNumber.sprintf("%05d",l);
2503 if (fileName && !sourceFileName.isEmpty())
2505 QCString lineAnchor;
2506 lineAnchor.sprintf("_l%05d",l);
2507 lineAnchor.prepend(sourceFileName);
2508 startCodeAnchor(lineAnchor);
2509 writeCodeLink(ref,fileName,anchor,lineNumber,0);
2524 void LatexGenerator::startCodeLine(bool)
2529 void LatexGenerator::endCodeLine()
2534 void LatexGenerator::startFontClass(const char *name)
2536 //if (!m_prettyCode) return;
2537 t << "\\textcolor{" << name << "}{";
2540 void LatexGenerator::endFontClass()
2542 //if (!m_prettyCode) return;
2546 void LatexGenerator::startCodeAnchor(const char *name)
2548 static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
2549 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
2550 //if (!m_prettyCode) return;
2551 if (usePDFLatex && pdfHyperlinks)
2553 t << "\\hypertarget{" << stripPath(name) << "}{}";
2557 void LatexGenerator::endCodeAnchor()
2561 void LatexGenerator::startInlineHeader()
2563 if (Config_getBool("COMPACT_LATEX"))
2565 t << "\\paragraph*{";
2569 t << "\\subsubsection*{";
2573 void LatexGenerator::endInlineHeader()
2578 void LatexGenerator::lineBreak(const char *)
2590 void LatexGenerator::startMemberDocSimple()
2592 t << "\\begin{DoxyFields}{";
2593 docify(theTranslator->trCompoundMembers());
2597 void LatexGenerator::endMemberDocSimple()
2599 t << "\\end{DoxyFields}" << endl;
2602 void LatexGenerator::startInlineMemberType()
2606 void LatexGenerator::endInlineMemberType()
2611 void LatexGenerator::startInlineMemberName()
2615 void LatexGenerator::endInlineMemberName()
2620 void LatexGenerator::startInlineMemberDoc()
2624 void LatexGenerator::endInlineMemberDoc()
2626 t << "\\\\\n\\hline\n" << endl;
2629 void LatexGenerator::startLabels()
2631 t << "\\hspace{0.3cm}";
2634 void LatexGenerator::writeLabel(const char *l,bool isLast)
2636 t << "{\\ttfamily [" << l << "]}";
2637 if (!isLast) t << ", ";
2640 void LatexGenerator::endLabels()