Skip to content

Commit 0e398ae

Browse files
committed
issue doxygen#11939 LaTeX output does not properly break lines with long doxylink
There following parts are fixed: - 5. Index Introducing the LaTeX environment `doxyIndexDescription` and setting an extra flag `escapeUnderscore` for the function `latexEscapeIndexChars` to false. - 4. Section title Using the `escapeUnderscore` flag to determine wheter or not the "word breaking" doxygen LaTeX command `\+` can be used (was by default set to `true` in the `filterLatexString`, when always usingh `false` would lead to TeX capacity exceeded or to `\+` in the index output). - 1. File Index Solved due to point 4.
1 parent be35cfa commit 0e398ae

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/latexgen.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,7 @@ QCString latexEscapeLabelName(const QCString &s)
25632563
return t.str();
25642564
}
25652565

2566-
QCString latexEscapeIndexChars(const QCString &s)
2566+
QCString latexEscapeIndexChars(const QCString &s, bool escapeUnderscore)
25672567
{
25682568
//printf("latexEscapeIndexChars(%s)\n",qPrint(s));
25692569
if (s.isEmpty()) return s;
@@ -2583,6 +2583,7 @@ QCString latexEscapeIndexChars(const QCString &s)
25832583
case ']': t << "]"; break;
25842584
case '{': t << "\\lcurly{}"; break;
25852585
case '}': t << "\\rcurly{}"; break;
2586+
case '_': if (!escapeUnderscore) {t << "_"; break;}
25862587
// NOTE: adding a case here, means adding it to while below as well!
25872588
default:
25882589
{
@@ -2591,12 +2592,13 @@ QCString latexEscapeIndexChars(const QCString &s)
25912592
tmp[i++]=c;
25922593
while ((c=*p) && c!='"' && c!='@' && c!='[' && c!=']' && c!='!' && c!='{' && c!='}' && c!='|')
25932594
{
2595+
if (c=='_' && !escapeUnderscore) break;
25942596
tmp[i++]=c;
25952597
p++;
25962598
}
25972599
tmp[i]=0;
25982600
filterLatexString(t,tmp,
2599-
true, // insideTabbing
2601+
!escapeUnderscore, // "insideTabbing"
26002602
false, // insidePre
26012603
false, // insideItem
26022604
false, // insideTable
@@ -2674,16 +2676,16 @@ void latexWriteIndexItem(TextStream &m_t,const QCString &s1,const QCString &s2)
26742676
{
26752677
m_t << "\\index{";
26762678
m_t << latexEscapeLabelName(s1);
2677-
m_t << "@{";
2678-
m_t << latexEscapeIndexChars(s1);
2679-
m_t << "}";
2679+
m_t << "@{\\doxyIndexDescription{";
2680+
m_t << latexEscapeIndexChars(s1,false);
2681+
m_t << "}}";
26802682
if (!s2.isEmpty())
26812683
{
26822684
m_t << "!";
26832685
m_t << latexEscapeLabelName(s2);
2684-
m_t << "@{";
2685-
m_t << latexEscapeIndexChars(s2);
2686-
m_t << "}";
2686+
m_t << "@{\\doxyIndexDescription{";
2687+
m_t << latexEscapeIndexChars(s2,false);
2688+
m_t << "}}";
26872689
}
26882690
m_t << "}\n";
26892691
}

src/latexgen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ void filterLatexString(TextStream &t,const QCString &str,
344344
const bool retainNewline = false);
345345

346346
QCString latexEscapeLabelName(const QCString &s);
347-
QCString latexEscapeIndexChars(const QCString &s);
347+
QCString latexEscapeIndexChars(const QCString &s, bool escapeUnderscore = true);
348348
QCString latexEscapePDFString(const QCString &s);
349349
QCString latexFilterURL(const QCString &s);
350350
void latexWriteIndexItem(TextStream &t,const QCString &r1,const QCString &s2 = "");

templates/latex/header.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
\newenvironment{NoHyper}{}{}
4343
%%END !PDF_HYPERLINKS
4444
45+
\usepackage{xurl}
46+
\newcommand{\doxyIndexDescription}[1]{%
47+
\begin{NoHyper}\url{#1}\end{NoHyper}%
48+
}
49+
4550
\usepackage{doxygen}
4651
4752
$extralatexstylesheet

0 commit comments

Comments
 (0)