diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2018-07-23 19:08:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-23 19:08:06 (GMT) |
commit | 8032111d5e1baf0d4c017be6f6eea2aaa10ad26b (patch) | |
tree | 760015456f1166f992f7205921109465bdfd8bd1 | |
parent | 198abce439d91d9d877570ec335bfd26a31d8526 (diff) | |
parent | 0f8902275a4c02196d4eb1398e621a349355410a (diff) | |
download | Doxygen-8032111d5e1baf0d4c017be6f6eea2aaa10ad26b.zip Doxygen-8032111d5e1baf0d4c017be6f6eea2aaa10ad26b.tar.gz Doxygen-8032111d5e1baf0d4c017be6f6eea2aaa10ad26b.tar.bz2 |
Merge pull request #6405 from albert-github/feature/bug_latex_special_chars
Improvements in handling special characters in LaTeX
-rw-r--r-- | src/util.cpp | 37 | ||||
-rw-r--r-- | templates/latex/doxygen.sty | 13 |
2 files changed, 28 insertions, 22 deletions
diff --git a/src/util.cpp b/src/util.cpp index a0522d4..6c7e3d5 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -6741,6 +6741,16 @@ void filterLatexString(FTextStream &t,const char *str, { switch(c) { + case 0xef: // handle U+FFFD i.e. "Replacement character" caused by octal: 357 277 275 / hexadecimal 0xef 0xbf 0xbd + // the LaTeX command \ucr has been defined in doxygen.sty + if ((unsigned char)*(p) == 0xbf && (unsigned char)*(p+1) == 0xbd) + { + t << "{\\ucr}"; + p += 2; + } + else + t << (char)c; + break; case '\\': t << "\\(\\backslash\\)"; break; case '{': t << "\\{"; break; case '}': t << "\\}"; break; @@ -6762,6 +6772,16 @@ void filterLatexString(FTextStream &t,const char *str, { switch(c) { + case 0xef: // handle U+FFFD i.e. "Replacement character" caused by octal: 357 277 275 / hexadecimal 0xef 0xbf 0xbd + // the LaTeX command \ucr has been defined in doxygen.sty + if ((unsigned char)*(p) == 0xbf && (unsigned char)*(p+1) == 0xbd) + { + t << "{\\ucr}"; + p += 2; + } + else + t << (char)c; + break; case '#': t << "\\#"; break; case '$': t << "\\$"; break; case '%': t << "\\%"; break; @@ -8865,19 +8885,10 @@ void writeLatexSpecialFormulaChars(FTextStream &t) 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" + t << "\\usepackage{newunicodechar}\n" + " \\newunicodechar{" << pminus << "}{${}^{-}$}% Superscript minus\n" + " \\newunicodechar{" << psup2 << "}{${}^{2}$}% Superscript two\n" + " \\newunicodechar{" << psup3 << "}{${}^{3}$}% Superscript three\n" "\n"; } diff --git a/templates/latex/doxygen.sty b/templates/latex/doxygen.sty index 842d101..7798d48 100644 --- a/templates/latex/doxygen.sty +++ b/templates/latex/doxygen.sty @@ -87,6 +87,8 @@ % Necessary for redefining not defined charcaters, i.e. "Replacement Character" in tex output. \newlength{\CodeWidthChar} \newlength{\CodeHeightChar} +\settowidth{\CodeWidthChar}{?} +\settoheight{\CodeHeightChar}{?} % Necessary for hanging indent \newlength{\DoxyCodeWidth} @@ -117,6 +119,8 @@ }{% \normalfont% \normalsize% + \settowidth{\CodeWidthChar}{?}% + \settoheight{\CodeHeightChar}{?}% } % Redefining not defined characters, i.e. "Replacement Character" in tex output. @@ -124,15 +128,6 @@ \textcolor{white}{\sffamily\bfseries\small ?}}{% \rotatebox{45}{$\blacksquare$}}}} -% Choosing right setup for "Replacement character" -\ifthenelse{\isundefined{\DeclareUnicodeCharacter}}{% - \catcode`\�=13 - \def�{\ucr} -}{% - \RequirePackage[utf8]{inputenc} - \DeclareUnicodeCharacter{FFFD}{\ucr} -} - % Used by @example, @include, @includelineno and @dontinclude \newenvironment{DoxyCodeInclude}[1]{% \DoxyCode{#1}% |