diff options
author | albert-github <albert.tests@gmail.com> | 2018-05-30 17:33:17 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2018-05-30 17:33:17 (GMT) |
commit | d984f7dd21863fc01a1a6ede0878d3dd14af157a (patch) | |
tree | 29f9a7f7a6875135e7083ab96f46c6a7169b225a /src/latexdocvisitor.cpp | |
parent | 63696c08425fc1662c5e76280e3cc74fb3769d80 (diff) | |
download | Doxygen-d984f7dd21863fc01a1a6ede0878d3dd14af157a.zip Doxygen-d984f7dd21863fc01a1a6ede0878d3dd14af157a.tar.gz Doxygen-d984f7dd21863fc01a1a6ede0878d3dd14af157a.tar.bz2 |
Problems and some enhancements for LaTeX tables
- Possibility to honor also the cell alignment when using Markdown tables for other formats (markdown.cpp, latexdocvisitor.cpp, lines: 1146, 1157, 1173)
latexdocvisitor.cpp:
- Possibility to nest tables to a further level when using LaTeX. It was only possible till level 2 (i.e. a longtabu followed buy a tabularx table). By placing tabularx in an extra set of brackets this is fixed (lines 938 and 951)
- tablarx environment cannot handle the headers as used for the longtabu table. A header line is in case of tabularx implemented by mimicking the header line.
- longtabu needs multiple times the header line (first and following), tabularx we only need 1 (line 998)
- no longtabu special headers (line 1092)
- tabularx cannot handle rowcolor, coloring done only with columncolor(line 1024, 1134, 1188)
- no necessity for longtabu to define column with for spanned columns / rows(line 1048, 1134, 1171)
Diffstat (limited to 'src/latexdocvisitor.cpp')
-rw-r--r-- | src/latexdocvisitor.cpp | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 86ceade..e268006 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -935,7 +935,7 @@ static void writeStartTableCommand(FTextStream &t,const DocNode *n,int cols) { if (tableIsNested(n)) { - t << "\\begin{tabularx}{\\linewidth}{|*{" << cols << "}{>{\\raggedright\\arraybackslash}X|}}"; + t << "{\\begin{tabularx}{\\linewidth}{|*{" << cols << "}{>{\\raggedright\\arraybackslash}X|}}"; } else { @@ -948,7 +948,7 @@ static void writeEndTableCommand(FTextStream &t,const DocNode *n) { if (tableIsNested(n)) { - t << "\\end{tabularx}\n"; + t << "\\end{tabularx}}\n"; } else { @@ -995,7 +995,8 @@ void LatexDocVisitor::visitPre(DocHtmlTable *t) if (firstRow && firstRow->isHeading()) { setFirstRow(TRUE); - firstRow->accept(this); + DocNode *n = t->parent(); + if (!tableIsNested(n)) firstRow->accept(this); setFirstRow(FALSE); } } @@ -1021,13 +1022,14 @@ void LatexDocVisitor::visitPost(DocHtmlCaption *c) void LatexDocVisitor::visitPre(DocHtmlRow *r) { setCurrentColumn(0); - if (r->isHeading()) m_t << "\\rowcolor{\\tableheadbgcolor}"; } void LatexDocVisitor::visitPost(DocHtmlRow *row) { if (m_hide) return; + DocNode *n = row->parent() ->parent(); + int c=currentColumn(); while (c<=numCols()) // end of row while inside a row span? { @@ -1045,10 +1047,7 @@ void LatexDocVisitor::visitPost(DocHtmlRow *row) if (span->colSpan>1) // row span is also part of a column span { m_t << "\\multicolumn{" << span->colSpan << "}{"; - m_t << "p{(\\linewidth-\\tabcolsep*" - << numCols() << "-\\arrayrulewidth*" - << row->visibleCells() << ")*" - << span->colSpan <<"/"<< numCols() << "}|}{}"; + m_t << "}|}{}"; } else // solitary row span { @@ -1089,7 +1088,8 @@ void LatexDocVisitor::visitPost(DocHtmlRow *row) m_t << "\n"; - if (row->isHeading() && row->rowIndex()==1) + + if (row->isHeading() && row->rowIndex()==1 && !tableIsNested(n)) { if (firstRow()) { @@ -1131,10 +1131,7 @@ void LatexDocVisitor::visitPre(DocHtmlCell *c) { m_t << "|"; } - m_t << "p{(\\linewidth-\\tabcolsep*" - << numCols() << "-\\arrayrulewidth*" - << row->visibleCells() << ")*" - << span->colSpan <<"/"<< numCols() << "}|}{}"; + m_t << "l|}{" << (c->isHeading()? "\\columncolor{\\tableheadbgcolor}" : "") << "}"; // alignment not relevant, empty column setCurrentColumn(currentColumn()+span->colSpan); } else @@ -1146,6 +1143,7 @@ void LatexDocVisitor::visitPre(DocHtmlCell *c) } int cs = c->colSpan(); + int a = c->alignment(); if (cs>1 && row) { setInColSpan(TRUE); @@ -1154,11 +1152,18 @@ void LatexDocVisitor::visitPre(DocHtmlCell *c) { m_t << "|"; } - m_t << "p{(\\linewidth-\\tabcolsep*" - << numCols() << "-\\arrayrulewidth*" - << row->visibleCells() << ")*" - << cs <<"/"<< numCols() << "}|}{"; - if (c->isHeading()) m_t << "\\cellcolor{\\tableheadbgcolor}"; + switch (a) + { + case DocHtmlCell::Right: + m_t << "r|}{"; + break; + case DocHtmlCell::Center: + break; + m_t << "c|}{"; + default: + m_t << "l|}{"; + break; + } } int rs = c->rowSpan(); if (rs>0) @@ -1168,9 +1173,8 @@ void LatexDocVisitor::visitPre(DocHtmlCell *c) // c->rowIndex(),c->columnIndex(),c->rowSpan(),c->colSpan(), // currentColumn()); addRowSpan(new ActiveRowSpan(c,rs,cs,currentColumn())); - m_t << "\\multirow{" << rs << "}{\\linewidth}{"; + m_t << "\\multirow{" << rs << "}{*}{"; } - int a = c->alignment(); if (a==DocHtmlCell::Center) { m_t << "\\PBS\\centering "; @@ -1181,7 +1185,7 @@ void LatexDocVisitor::visitPre(DocHtmlCell *c) } if (c->isHeading()) { - m_t << "\\textbf{ "; + m_t << "\\cellcolor{\\tableheadbgcolor}\\textbf{ "; } if (cs>1) { |