diff options
Diffstat (limited to 'src/latexgen.cpp')
-rw-r--r-- | src/latexgen.cpp | 255 |
1 files changed, 151 insertions, 104 deletions
diff --git a/src/latexgen.cpp b/src/latexgen.cpp index f3d8110..1a19618 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -146,12 +146,24 @@ void LatexGenerator::init() << endl << "ps: refman.ps" << endl << endl - << "pdf: ps" << endl - << "\tps2pdf refman.ps refman.pdf" << endl + << "pdf: refman.pdf" << endl + << endl + << "ps_2on1: refman_2on1.ps" << endl + << endl + << "pdf_2on1: refman_2on1.pdf" << endl << endl << "refman.ps: refman.dvi" << endl << "\tdvips -o refman.ps refman.dvi" << endl << endl + << "refman.pdf: refman.ps" << endl + << "\tps2pdf refman.ps refman.pdf" << endl + << endl + << "refman_2on1.ps: refman.ps" << endl + << "\tpsnup -2 refman.ps >refman_2on1.ps" << endl + << endl + << "refman_2on1.pdf: refman_2on1.ps" << endl + << "\tps2pdf refman_2on1.ps refman_2on1.pdf" << endl + << endl << "refman.dvi: refman.tex doxygen.sty" << endl << "\techo \"Running latex...\"" << endl << "\tlatex refman.tex" << endl @@ -163,6 +175,117 @@ void LatexGenerator::init() << "\trm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out" << endl; } +static void writeDefaultsStyleSheetPart1(QTextStream &t) +{ + // part 1 + + QCString paperName; + if (Config::latexBatchModeFlag) t << "\\batchmode" << endl; + if (Config::paperType=="a4wide") paperName="a4"; else paperName=Config::paperType; + t << "\\documentclass[" << paperName << "paper"; + if (Config::pdfHyperFlag) t << ",ps2pdf"; + t << "]{"; + if (Config::compactLatexFlag) t << "article"; else t << "book"; + t << "}\n"; + if (Config::paperType=="a4wide") t << "\\usepackage{a4wide}\n"; + t << "\\usepackage{makeidx}\n" + "\\usepackage{fancyhdr}\n" + "\\usepackage{graphicx}\n" + "\\usepackage{float}\n" + "\\usepackage{doxygen}\n"; + if (Config::pdfHyperFlag) + { + t << "\\usepackage{times}" << endl + << "\\usepackage[backref=true," << endl + << " pagebackref=true," << endl + << " colorlinks=true," << endl + << " linkcolor=blue" << endl + << " ]{hyperref}" << endl; + } + // Try to get the command for switching on the language + // support + QCString sLanguageSupportCommand( + theTranslator->latexLanguageSupportCommand()); + + if (!sLanguageSupportCommand.isEmpty()) + { + // The command is not empty. The language does + // not want to use the babel package. Use this + // command instead. + t << sLanguageSupportCommand; + } + else + { + if (!theTranslator->latexBabelPackage().isEmpty()) + { + // The result of the LatexLanguageSupportCommand() + // is empty, which means that the language prefers + // the babel package, or no package is needed at all. + if (theTranslator->latexBabelPackage()=="russian") + { + // The russian babel package also needs an encoding. + // Assume the encoding matched the platform. +#if defined(_WIN32) + t << "\\usepackage[cp1251]{inputenc}\n"; +#else + t << "\\usepackage[koi8-r]{inputenc}\n"; +#endif + } + t << "\\usepackage[" << theTranslator->latexBabelPackage() << "]{babel}\n"; + } + } + + const char *s=Config::extraPackageList.first(); + while (s) + { + t << "\\usepackage{" << s << "}\n"; + s=Config::extraPackageList.next(); + } + t << "\\makeindex\n" + "\\setcounter{tocdepth}{1}\n" + "\\setlength{\\footrulewidth}{0.4pt}\n" + "\\begin{document}\n" + "\\begin{titlepage}\n" + "\\vspace*{7cm}\n" + "\\begin{center}\n" + "{\\Large "; + +} + +static void writeDefaultsStyleSheetPart2(QTextStream &t) +{ + // part 2 + t << "}\\\\" << endl + << "\\vspace*{1cm}" << endl + << "{\\large "; +} + +static void writeDefaultsStyleSheetPart3(QTextStream &t) +{ + // part 3 + t << " Doxygen " << versionString << "}\\\\" << endl + << "\\vspace*{0.5cm}" << endl + << "{\\small " << dateToString(TRUE) << "}\\\\" << endl + << "\\end{center}" << endl + << "\\end{titlepage}" << endl; + if (!Config::compactLatexFlag) t << "\\clearemptydoublepage\n"; + t << "\\pagenumbering{roman}\n"; + t << "\\tableofcontents\n"; + if (!Config::compactLatexFlag) t << "\\clearemptydoublepage\n"; + t << "\\pagenumbering{arabic}\n"; +} + +void LatexGenerator::writeStyleSheetFile(QFile &f) +{ + QTextStream t(&f); + writeDefaultsStyleSheetPart1(t); + t << "Your title here"; + writeDefaultsStyleSheetPart2(t); + t << "Generated by"; + writeDefaultsStyleSheetPart3(t); +} + + void LatexGenerator::startFile(const char *name,const char *,bool) { QCString fileName=name; @@ -187,82 +310,13 @@ void LatexGenerator::startProjectNumber() void LatexGenerator::startIndexSection(IndexSections is) { - QCString paperName; switch (is) { case isTitlePageStart: { if (Config::latexHeaderFile.isEmpty()) { - if (Config::latexBatchModeFlag) t << "\\batchmode" << endl; - if (Config::paperType=="a4wide") paperName="a4"; else paperName=Config::paperType; - t << "\\documentclass[" << paperName << "paper"; - if (Config::pdfHyperFlag) t << ",ps2pdf"; - t << "]{"; - if (Config::compactLatexFlag) t << "article"; else t << "book"; - t << "}\n"; - if (Config::paperType=="a4wide") t << "\\usepackage{a4wide}\n"; - t << "\\usepackage{makeidx}\n" - "\\usepackage{fancyhdr}\n" - "\\usepackage{epsfig}\n" - "\\usepackage{float}\n" - "\\usepackage{doxygen}\n"; - if (Config::pdfHyperFlag) - { - t << "\\usepackage{times}" << endl - << "\\usepackage[backref=true," << endl - << " pagebackref=true," << endl - << " colorlinks=true," << endl - << " linkcolor=blue" << endl - << " ]{hyperref}" << endl; - } - // Try to get the command for switching on the language - // support - QCString sLanguageSupportCommand( - theTranslator->latexLanguageSupportCommand()); - - if (!sLanguageSupportCommand.isEmpty()) - { - // The command is not empty. The language does - // not want to use the babel package. Use this - // command instead. - t << sLanguageSupportCommand; - } - else - { - if (!theTranslator->latexBabelPackage().isEmpty()) - { - // The result of the LatexLanguageSupportCommand() - // is empty, which means that the language prefers - // the babel package, or no package is needed at all. - if (theTranslator->latexBabelPackage()=="russian") - { - // The russian babel package also needs an encoding. - // Assume the encoding matched the platform. -#if defined(_WIN32) - t << "\\usepackage[cp1251]{inputenc}\n"; -#else - t << "\\usepackage[koi8-r]{inputenc}\n"; -#endif - } - t << "\\usepackage[" << theTranslator->latexBabelPackage() << "]{babel}\n"; - } - } - - const char *s=Config::extraPackageList.first(); - while (s) - { - t << "\\usepackage{" << s << "}\n"; - s=Config::extraPackageList.next(); - } - t << "\\makeindex\n" - "\\setcounter{tocdepth}{1}\n" - "\\setlength{\\footrulewidth}{0.4pt}\n" - "\\begin{document}\n" - "\\begin{titlepage}\n" - "\\vspace*{7cm}\n" - "\\begin{center}\n" - "{\\Large "; + writeDefaultsStyleSheetPart1(t); } else { @@ -274,9 +328,7 @@ void LatexGenerator::startIndexSection(IndexSections is) case isTitlePageAuthor: if (Config::latexHeaderFile.isEmpty()) { - t << "}\\\\" << endl - << "\\vspace*{1cm}" << endl - << "{\\large "; + writeDefaultsStyleSheetPart2(t); } break; case isMainPage: @@ -406,16 +458,7 @@ void LatexGenerator::endIndexSection(IndexSections is) case isTitlePageAuthor: if (Config::latexHeaderFile.isEmpty()) { - t << " Doxygen " << versionString << "}\\\\" << endl - << "\\vspace*{0.5cm}" << endl - << "{\\small " << dateToString(TRUE) << "}\\\\" << endl - << "\\end{center}" << endl - << "\\end{titlepage}" << endl; - if (!Config::compactLatexFlag) t << "\\clearemptydoublepage\n"; - t << "\\pagenumbering{roman}\n"; - t << "\\tableofcontents\n"; - if (!Config::compactLatexFlag) t << "\\clearemptydoublepage\n"; - t << "\\pagenumbering{arabic}\n"; + writeDefaultsStyleSheetPart3(t); } break; case isMainPage: @@ -1108,15 +1151,15 @@ void LatexGenerator::docify(const char *str) break; case '"': if (isGerman) // " has a special meaning if German // - Thomas Vesper - { t << "\\char`\\\""; } + { t << "\\char`\\\"{}"; } else { t << (char)c; } break; default: if (isJapanese) - { // language is japanese - if (c>=128) // wide character + { // Japanese language uses wide characters + if (c>=128) { t << (char)c; if (*p) @@ -1125,25 +1168,25 @@ void LatexGenerator::docify(const char *str) t << (char)c; } } - else // ascii char => see if we can insert hypenation hint + else // ascii char => see if we can insert a hypenation hint { if (isupper(c) && islower(pc) && !insideTabbing) t << "\\-"; t << (char)c; } } - else if (isRussian) + else if (isCzech || isRussian) { if (c>=128) { t << (char)c; } - else + else // ascii char => see if we can insert a hypenation hint { if (isupper(c) && islower(pc) && !insideTabbing) t << "\\-"; t << (char)c; } } - else // language is other than russian or japanese + else // language is other than Czech, Russian or Japanese { switch(c) { @@ -1156,8 +1199,8 @@ void LatexGenerator::docify(const char *str) case 194: t << "\\^{A}"; break; case 195: t << "\\~{A}"; break; case 196: t << "\\\"{A}"; break; - case 197: t << "\\AA "; break; - case 198: t << "\\AE "; break; + case 197: t << "\\AA{}"; break; + case 198: t << "\\AE{}"; break; case 199: t << "\\c{C}"; break; case 200: t << "\\`{E}"; break; case 201: t << "\\'{E}"; break; @@ -1181,14 +1224,14 @@ void LatexGenerator::docify(const char *str) case 219: t << "\\^{U}"; break; case 220: t << "\\\"{U}"; break; case 221: t << "\\'{Y}"; break; - case 223: t << "\\ss "; break; + case 223: t << "\\ss{}"; break; case 224: t << "\\`{a}"; break; case 225: t << "\\'{a}"; break; case 226: t << "\\^{a}"; break; case 227: t << "\\~{a}"; break; case 228: t << "\\\"{a}"; break; - case 229: t << "\\aa "; break; - case 230: t << "\\ae "; break; + case 229: t << "\\aa{}"; break; + case 230: t << "\\ae{}"; break; case 231: t << "\\c{c}"; break; case 232: t << "\\`{e}"; break; case 233: t << "\\'{e}"; break; @@ -1204,7 +1247,7 @@ void LatexGenerator::docify(const char *str) case 244: t << "\\^{o}"; break; case 245: t << "\\~{o}"; break; case 246: t << "\\\"{o}"; break; - case 248: t << "\\o "; break; + case 248: t << "\\o{}"; break; case 249: t << "\\`{u}"; break; case 250: t << "\\'{u}"; break; case 251: t << "\\^{u}"; break; @@ -1331,12 +1374,16 @@ void LatexGenerator::endMemberList() void LatexGenerator::writeImage(const char *name,const char *w,const char *h) { - t << "\\mbox{\\epsfig{file=" << name; - if (w) - t << "," << w; - else if (h) - t << "," << h; - t << "}}" << endl; + t << "\\mbox{"; + QCString gfxName = name; + if (gfxName.right(4)==".eps") gfxName.left(gfxName.length()-4); + // "\\epsfig{file=" << name; + t << "\\includegraphics"; + if (w || h) t << "["; + if (w) t << "width=" << w; else if (h) t << "height=" << h; + if (w || h) t << "]"; + t << "{" << gfxName << "}"; + t << "}" << endl; } void LatexGenerator::startMemberGroupHeader(bool hasHeader) |