Skip to content

Commit 7f87ae7

Browse files
committed
issue doxygen#11702 LaTeX output does not properly break lines with long indexed parameters
making the `\mbox` usage a bit more sophisticated (checking the length so long links can be wrapped) using `\doxymbox`. Based on - idea from https://tex.stackexchange.com/a/18577/44119 , there were problems with a.o. `\hbox` in hyperlinks, so using: - strategy / code used for length determination of tables
1 parent 9b709ad commit 7f87ae7

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

src/latexdocvisitor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static void visitPreStart(TextStream &t, bool hasCaption, QCString name, QCStri
122122
else
123123
{
124124
t << "\n\\begin{DoxyImageNoCaption}%\n"
125-
" \\mbox{";
125+
" \\doxymbox{";
126126
}
127127
}
128128

@@ -194,7 +194,7 @@ static void visitPostEnd(TextStream &t, bool hasCaption, bool inlineImage = FALS
194194
}
195195
else
196196
{
197-
t << "}%\n"; // end mbox or caption
197+
t << "}%\n"; // end doxymbox or caption
198198
if (hasCaption)
199199
{
200200
t << "\\end{DoxyImage}\n";
@@ -1737,7 +1737,7 @@ void LatexDocVisitor::operator()(const DocParamList &pl)
17371737
{
17381738
if (pl.direction()!=DocParamSect::Unspecified)
17391739
{
1740-
m_t << "\\mbox{\\texttt{";
1740+
m_t << "\\doxymbox{\\texttt{";
17411741
if (pl.direction()==DocParamSect::In)
17421742
{
17431743
m_t << "in";
@@ -1804,7 +1804,7 @@ void LatexDocVisitor::operator()(const DocXRefItem &x)
18041804
m_t << "\\item[";
18051805
if (pdfHyperlinks && !anonymousEnum)
18061806
{
1807-
m_t << "\\mbox{\\hyperlink{" << stripPath(x.file()) << "_" << x.anchor() << "}{";
1807+
m_t << "\\doxymbox{\\hyperlink{" << stripPath(x.file()) << "_" << x.anchor() << "}{";
18081808
}
18091809
else
18101810
{

src/latexgen.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void LatexCodeGenerator::writeCodeLink(CodeSymbolType,
204204
size_t l = name.length();
205205
if (ref.isEmpty() && usePDFLatex && pdfHyperlinks)
206206
{
207-
*m_t << "\\mbox{\\hyperlink{";
207+
*m_t << "\\doxymbox{\\hyperlink{";
208208
if (!f.isEmpty()) *m_t << stripPath(f);
209209
if (!f.isEmpty() && !anchor.isEmpty()) *m_t << "_";
210210
if (!anchor.isEmpty()) *m_t << anchor;
@@ -1381,7 +1381,7 @@ void LatexGenerator::startTextLink(const QCString &f,const QCString &anchor)
13811381
bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
13821382
if (!m_disableLinks && pdfHyperlinks)
13831383
{
1384-
m_t << "\\mbox{\\hyperlink{";
1384+
m_t << "\\doxymbox{\\hyperlink{";
13851385
if (!f.isEmpty()) m_t << stripPath(f);
13861386
if (!anchor.isEmpty()) m_t << "_" << anchor;
13871387
m_t << "}{";
@@ -1410,7 +1410,7 @@ static QCString objectLinkToString(const QCString &ref, const QCString &f,
14101410
QCString result;
14111411
if (!disableLinks && ref.isEmpty() && pdfHyperlinks)
14121412
{
1413-
result += "\\mbox{\\hyperlink{";
1413+
result += "\\doxymbox{\\hyperlink{";
14141414
if (!f.isEmpty()) result += stripPath(f);
14151415
if (!f.isEmpty() && !anchor.isEmpty()) result += "_";
14161416
if (!anchor.isEmpty()) result += anchor;
@@ -1632,7 +1632,7 @@ void LatexGenerator::startDoxyAnchor(const QCString &fName,const QCString &,
16321632
{
16331633
bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
16341634
bool usePDFLatex = Config_getBool(USE_PDFLATEX);
1635-
if (m_insideTableEnv) m_t << "\\mbox{"; // see issue #6093
1635+
if (m_insideTableEnv) m_t << "\\doxymbox{"; // see issue #6093
16361636
if (usePDFLatex && pdfHyperlinks)
16371637
{
16381638
m_t << "\\Hypertarget{";
@@ -2484,13 +2484,13 @@ void filterLatexString(TextStream &t,const QCString &str,
24842484
case '|': processEntity(t,pdfHyperlinks,"$\\vert$","|"); break;
24852485
case '~': processEntity(t,pdfHyperlinks,"$\\sim$","\\string~"); break;
24862486
case '[': if (Config_getBool(PDF_HYPERLINKS) || insideItem)
2487-
t << "\\mbox{[}";
2487+
t << "\\+[";
24882488
else
24892489
t << "[";
24902490
break;
24912491
case ']': if (pc=='[') t << "$\\,$";
24922492
if (Config_getBool(PDF_HYPERLINKS) || insideItem)
2493-
t << "\\mbox{]}";
2493+
t << "]\\+";
24942494
else
24952495
t << "]";
24962496
break;

templates/latex/doxygen.sty

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,21 @@
657657
\end{list}%
658658
}
659659

660+
\newsavebox{\doxymboxbox}
661+
\newlength{\doxymboxlength}
662+
\newcommand{\doxymbox}[1]{%
663+
\sbox{\doxymboxbox}{#1}%
664+
\setlength{\doxymboxlength}{\wd\doxymboxbox}%
665+
\ifthenelse{\doxymboxlength>\linewidth}{%
666+
#1%
667+
}{%
668+
\mbox{#1}%
669+
}%
670+
}
671+
660672
% Used when hyperlinks are turned on
661673
\newcommand{\doxylink}[2]{%
662-
\mbox{\hyperlink{#1}{#2}}%
674+
\doxymbox{\hyperlink{#1}{#2}}%
663675
}
664676

665677
% Used for the cite command
@@ -697,7 +709,7 @@
697709
% Third argument is the SectionType, see the doxygen internal
698710
% documentation for the values (relevant: Page ... Subsubsection).
699711
\newcommand{\doxysectlink}[3]{%
700-
\mbox{\hyperlink{#1}{#2}}%
712+
\doxymbox{\hyperlink{#1}{#2}}%
701713
}
702714
% Used when hyperlinks are turned off
703715
\newcommand{\doxyref}[3]{%

0 commit comments

Comments
 (0)