diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2018-07-21 13:13:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-21 13:13:25 (GMT) |
commit | 5e05075b2eb5957739d6e32577f6b9643e6bbee6 (patch) | |
tree | afb60fa51be77c2ec4ce06f342e0dfaceffabeb8 | |
parent | 72b5d9ccf8e82930dac5dc4c847babcf41f7cc0a (diff) | |
parent | 7bb6b4792a95626685df5750a6ab79b675c9fd60 (diff) | |
download | Doxygen-5e05075b2eb5957739d6e32577f6b9643e6bbee6.zip Doxygen-5e05075b2eb5957739d6e32577f6b9643e6bbee6.tar.gz Doxygen-5e05075b2eb5957739d6e32577f6b9643e6bbee6.tar.bz2 |
Merge pull request #738 from albert-github/feature/bug_latex_code
Small problems when having code in LaTeX output
-rw-r--r-- | src/formula.cpp | 2 | ||||
-rw-r--r-- | src/latexgen.cpp | 37 | ||||
-rw-r--r-- | src/util.cpp | 35 | ||||
-rw-r--r-- | src/util.h | 1 | ||||
-rw-r--r-- | templates/latex/doxygen.sty | 12 |
5 files changed, 51 insertions, 36 deletions
diff --git a/src/formula.cpp b/src/formula.cpp index 46e2075..c252e07 100644 --- a/src/formula.cpp +++ b/src/formula.cpp @@ -69,8 +69,10 @@ void FormulaList::generateBitmaps(const char *path) FTextStream t(&f); if (Config_getBool(LATEX_BATCHMODE)) t << "\\batchmode" << endl; t << "\\documentclass{article}" << endl; + t << "\\usepackage{ifthen}" << endl; t << "\\usepackage{epsfig}" << endl; // for those who want to include images writeExtraLatexPackages(t); + writeLatexSpecialFormulaChars(t); t << "\\pagestyle{empty}" << endl; t << "\\begin{document}" << endl; int page=0; diff --git a/src/latexgen.cpp b/src/latexgen.cpp index ee29edc..d1580b8 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -182,7 +182,7 @@ void LatexCodeGenerator::writeCodeLink(const char *ref,const char *f, } else { - m_t << name; + codify(name); } m_col+=l; } @@ -650,28 +650,12 @@ static void writeDefaultHeaderPart1(FTextStream &t) "\n"; writeExtraLatexPackages(t); + writeLatexSpecialFormulaChars(t); // Hyperlinks bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS); if (pdfHyperlinks) { - unsigned char minus[4]; // Superscript minus - char *pminus = (char *)minus; - unsigned char sup2[3]; // Superscript two - char *psup2 = (char *)sup2; - unsigned char sup3[3]; - char *psup3 = (char *)sup3; // Superscript three - minus[0]= 0xE2; - minus[1]= 0x81; - minus[2]= 0xBB; - minus[3]= 0; - sup2[0]= 0xC2; - sup2[1]= 0xB2; - sup2[2]= 0; - sup3[0]= 0xC2; - sup3[1]= 0xB3; - sup3[2]= 0; - t << "% Hyperlinks (required, but should be loaded last)\n" "\\ifpdf\n" " \\usepackage[pdftex,pagebackref=true]{hyperref}\n" @@ -682,18 +666,6 @@ static void writeDefaultHeaderPart1(FTextStream &t) " \\usepackage[ps2pdf,pagebackref=true]{hyperref}\n" " \\fi\n" "\\fi\n" - "\\ifpdf\n" - " \\DeclareUnicodeCharacter{207B}{${}^{-}$}% Superscript minus\n" - " \\DeclareUnicodeCharacter{C2B2}{${}^{2}$}% Superscript two\n" - " \\DeclareUnicodeCharacter{C2B3}{${}^{3}$}% Superscript three\n" - "\\else\n" - " \\catcode`\\" << pminus << "=13% Superscript minus\n" - " \\def" << pminus << "{${}^{-}$}\n" - " \\catcode`\\" << psup2 << "=13% Superscript two\n" - " \\def" << psup2 << "{${}^{2}$}\n" - " \\catcode`\\"<<psup3<<"=13% Superscript three\n" - " \\def"<<psup3<<"{${}^{3}$}\n" - "\\fi\n" "\n" "\\hypersetup{%\n" " colorlinks=true,%\n" @@ -2239,6 +2211,11 @@ void LatexGenerator::startCodeFragment() void LatexGenerator::endCodeFragment() { + if (DoxyCodeOpen) + { + t << "}\n"; + DoxyCodeOpen = FALSE; + } t << "\\end{DoxyCode}\n"; DoxyCodeOpen = FALSE; } diff --git a/src/util.cpp b/src/util.cpp index 581ecfc..a0522d4 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -8846,6 +8846,41 @@ void writeExtraLatexPackages(FTextStream &t) } } +void writeLatexSpecialFormulaChars(FTextStream &t) +{ + unsigned char minus[4]; // Superscript minus + char *pminus = (char *)minus; + unsigned char sup2[3]; // Superscript two + char *psup2 = (char *)sup2; + unsigned char sup3[3]; + char *psup3 = (char *)sup3; // Superscript three + minus[0]= 0xE2; + minus[1]= 0x81; + minus[2]= 0xBB; + minus[3]= 0; + sup2[0]= 0xC2; + sup2[1]= 0xB2; + sup2[2]= 0; + sup3[0]= 0xC2; + sup3[1]= 0xB3; + sup3[2]= 0; + + t << "\\ifthenelse{\\isundefined{\\DeclareUnicodeCharacter}}{%\n" + " \\catcode`\\" << pminus << "=13% Superscript minus\n" + " \\def" << pminus << "{${}^{-}$}\n" + " \\catcode`\\" << psup2 << "=13% Superscript two\n" + " \\def" << psup2 << "{${}^{2}$}\n" + " \\catcode`\\"<<psup3<<"=13% Superscript three\n" + " \\def"<<psup3<<"{${}^{3}$}\n" + "}{%\n" + " \\DeclareUnicodeCharacter{207B}{${}^{-}$}% Superscript minus\n" + " \\DeclareUnicodeCharacter{C2B2}{${}^{2}$}% Superscript two\n" + " \\DeclareUnicodeCharacter{C2B3}{${}^{3}$}% Superscript three\n" + " \\DeclareUnicodeCharacter{2212}{-}% Just a minus sign\n" + "}\n" + "\n"; +} + //------------------------------------------------------ static int g_usedTableLevels = 0; @@ -478,6 +478,7 @@ void convertProtectionLevel( bool mainPageHasTitle(); bool openOutputFile(const char *outFile,QFile &f); void writeExtraLatexPackages(FTextStream &t); +void writeLatexSpecialFormulaChars(FTextStream &t); int usedTableLevels(); void incUsedTableLevels(); diff --git a/templates/latex/doxygen.sty b/templates/latex/doxygen.sty index 51e369b..842d101 100644 --- a/templates/latex/doxygen.sty +++ b/templates/latex/doxygen.sty @@ -119,19 +119,19 @@ \normalsize% } -% Redefining not defined charcaters, i.e. "Replacement Character" in tex output. +% Redefining not defined characters, i.e. "Replacement Character" in tex output. \def\ucr{\adjustbox{width=\CodeWidthChar,height=\CodeHeightChar}{\stackinset{c}{}{c}{-.2pt}{% \textcolor{white}{\sffamily\bfseries\small ?}}{% \rotatebox{45}{$\blacksquare$}}}} % Choosing right setup for "Replacement character" -\ifpdf - \RequirePackage[utf8]{inputenc} - \DeclareUnicodeCharacter{FFFD}{\ucr} -\else +\ifthenelse{\isundefined{\DeclareUnicodeCharacter}}{% \catcode`\�=13 \def�{\ucr} -\fi +}{% + \RequirePackage[utf8]{inputenc} + \DeclareUnicodeCharacter{FFFD}{\ucr} +} % Used by @example, @include, @includelineno and @dontinclude \newenvironment{DoxyCodeInclude}[1]{% |