Skip to content

Commit

Permalink
Improvement LaTeX output
Browse files Browse the repository at this point in the history
For a number of languages the output in LaTeX has been improved so the regular documentation can be generated (automatically) in LaTeX / PDF as well.
  • Loading branch information
albert-github committed Apr 9, 2018
1 parent 7e2fcd3 commit 66a728c
Show file tree
Hide file tree
Showing 36 changed files with 217 additions and 68 deletions.
9 changes: 5 additions & 4 deletions src/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2533,13 +2533,14 @@ EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
]]>
</docs>
</option>
<option type='string' id='LATEX_CMD_NAME' format='file' defval='latex' depends='GENERATE_LATEX'>
<option type='string' id='LATEX_CMD_NAME' format='file' defval='' depends='GENERATE_LATEX'>
<docs>
<![CDATA[
The \c LATEX_CMD_NAME tag can be used to specify the \f$\mbox{\LaTeX}\f$ command name to be invoked.
<br>Note that when enabling \ref cfg_use_pdflatex "USE_PDFLATEX" this option is only used for
generating bitmaps for formulas in the HTML output, but not in the
\c Makefile that is written to the output directory.
<br>Note that when not enabling \ref cfg_use_pdflatex "USE_PDFLATEX" the default is \c latex when
enabling \ref cfg_use_pdflatex "USE_PDFLATEX" the default is \cpdflatex and when in the later case
\c latex is chosen this is overwritten by \c pdflatex. For specific output languages the default can
have been set differently, this depends on the implementation of the output language.
]]>
</docs>
</option>
Expand Down
2 changes: 1 addition & 1 deletion src/dirdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include "doxygen.h"
#include "util.h"
#include "outputlist.h"
#include "config.h"
#include "language.h"
#include "message.h"
#include "dot.h"
#include "layout.h"
#include "ftextstream.h"
#include "config.h"
#include "docparser.h"

//----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/docbookvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "docbookvisitor.h"
#include "docparser.h"
#include "config.h"
#include "language.h"
#include "doxygen.h"
#include "outputgen.h"
Expand All @@ -29,7 +30,6 @@
#include "util.h"
#include "parserintf.h"
#include "filename.h"
#include "config.h"
#include "filedef.h"
#include "msc.h"
#include "dia.h"
Expand Down
2 changes: 1 addition & 1 deletion src/docparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "message.h"
#include "section.h"
#include "searchindex.h"
#include "config.h"
#include "language.h"
#include "portable.h"
#include "cite.h"
Expand All @@ -50,7 +51,6 @@
#include "namespacedef.h"
#include "reflist.h"
#include "formula.h"
#include "config.h"
#include "growbuf.h"
#include "markdown.h"
#include "htmlentity.h"
Expand Down
2 changes: 1 addition & 1 deletion src/filedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "classdef.h"
#include "namespacedef.h"
#include "util.h"
#include "config.h"
#include "language.h"
#include "outputlist.h"
#include "dot.h"
Expand All @@ -40,7 +41,6 @@
#include "filename.h"
#include "membergroup.h"
#include "dirdef.h"
#include "config.h"
#include "clangparser.h"
#include "settings.h"

Expand Down
4 changes: 2 additions & 2 deletions src/formula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "util.h"
#include "message.h"
#include "config.h"
#include "language.h"
#include "portable.h"
#include "index.h"
#include "doxygen.h"
Expand Down Expand Up @@ -96,8 +97,7 @@ void FormulaList::generateBitmaps(const char *path)
{
//printf("Running latex...\n");
//system("latex _formulas.tex </dev/null >/dev/null");
QCString latexCmd = Config_getString(LATEX_CMD_NAME);
if (latexCmd.isEmpty()) latexCmd="latex";
QCString latexCmd = theTranslator->latexCommandName();
portable_sysTimerStart();
if (portable_system(latexCmd,"_formulas.tex")!=0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/groupdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "classlist.h"
#include "outputlist.h"
#include "namespacedef.h"
#include "config.h"
#include "language.h"
#include "util.h"
#include "memberlist.h"
Expand All @@ -39,7 +40,6 @@
#include "entry.h"
#include "membername.h"
#include "dirdef.h"
#include "config.h"

//---------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/htmldocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#include <qdir.h>
#include "htmldocvisitor.h"
#include "docparser.h"
#include "config.h"
#include "language.h"
#include "doxygen.h"
#include "outputgen.h"
#include "dot.h"
#include "message.h"
#include "config.h"
#include "htmlgen.h"
#include "parserintf.h"
#include "msc.h"
Expand Down
2 changes: 1 addition & 1 deletion src/latexdocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <qfileinfo.h>
#include "latexdocvisitor.h"
#include "docparser.h"
#include "config.h"
#include "language.h"
#include "doxygen.h"
#include "outputgen.h"
Expand All @@ -30,7 +31,6 @@
#include "dia.h"
#include "cite.h"
#include "filedef.h"
#include "config.h"
#include "htmlentity.h"
#include "plantuml.h"

Expand Down
84 changes: 53 additions & 31 deletions src/latexgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,15 @@ static void writeLatexMakefile()
exit(1);
}
// inserted by KONNO Akihisa <konno@researchers.jp> 2002-03-05
QCString latex_command = Config_getString(LATEX_CMD_NAME);
QCString latex_command = theTranslator->latexCommandName();
QCString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME);
// end insertion by KONNO Akihisa <konno@researchers.jp> 2002-03-05
FTextStream t(&file);
if (!Config_getBool(USE_PDFLATEX)) // use plain old latex
{
t << "all: refman.dvi" << endl
t << "LATEX_CMD=" << latex_command << endl
<< endl
<< "all: refman.dvi" << endl
<< endl
<< "ps: refman.ps" << endl
<< endl
Expand All @@ -294,27 +296,27 @@ static void writeLatexMakefile()
t << "\tps2pdf refman.ps refman.pdf" << endl << endl;
t << "refman.dvi: clean refman.tex doxygen.sty" << endl
<< "\techo \"Running latex...\"" << endl
<< "\t" << latex_command << " refman.tex" << endl
<< "\t$(LATEX_CMD) refman.tex" << endl
<< "\techo \"Running makeindex...\"" << endl
<< "\t" << mkidx_command << " refman.idx" << endl;
if (generateBib)
{
t << "\techo \"Running bibtex...\"" << endl;
t << "\tbibtex refman" << endl;
t << "\techo \"Rerunning latex....\"" << endl;
t << "\t" << latex_command << " refman.tex" << endl;
t << "\t$(LATEX_CMD) refman.tex" << endl;
}
t << "\techo \"Rerunning latex....\"" << endl
<< "\t" << latex_command << " refman.tex" << endl
<< "\t$(LATEX_CMD) refman.tex" << endl
<< "\tlatex_count=8 ; \\" << endl
<< "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\" << endl
<< "\t do \\" << endl
<< "\t echo \"Rerunning latex....\" ;\\" << endl
<< "\t " << latex_command << " refman.tex ;\\" << endl
<< "\t $(LATEX_CMD) refman.tex ; \\" << endl
<< "\t latex_count=`expr $$latex_count - 1` ;\\" << endl
<< "\t done" << endl
<< "\t" << mkidx_command << " refman.idx" << endl
<< "\t" << latex_command << " refman.tex" << endl << endl
<< "\t$(LATEX_CMD) refman.tex" << endl << endl
<< "refman_2on1.ps: refman.ps" << endl
<< "\tpsnup -2 refman.ps >refman_2on1.ps" << endl
<< endl
Expand All @@ -323,26 +325,28 @@ static void writeLatexMakefile()
}
else // use pdflatex for higher quality output
{
t << "LATEX_CMD=" << latex_command << endl
<< endl;
t << "all: refman.pdf" << endl << endl
<< "pdf: refman.pdf" << endl << endl;
t << "refman.pdf: clean refman.tex" << endl;
t << "\tpdflatex refman" << endl;
t << "\t$(LATEX_CMD) refman" << endl;
t << "\t" << mkidx_command << " refman.idx" << endl;
if (generateBib)
{
t << "\tbibtex refman" << endl;
t << "\tpdflatex refman" << endl;
t << "\t$(LATEX_CMD) refman" << endl;
}
t << "\tpdflatex refman" << endl
t << "\t$(LATEX_CMD) refman" << endl
<< "\tlatex_count=8 ; \\" << endl
<< "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\" << endl
<< "\t do \\" << endl
<< "\t echo \"Rerunning latex....\" ;\\" << endl
<< "\t pdflatex refman ;\\" << endl
<< "\t $(LATEX_CMD) refman ;\\" << endl
<< "\t latex_count=`expr $$latex_count - 1` ;\\" << endl
<< "\t done" << endl
<< "\t" << mkidx_command << " refman.idx" << endl
<< "\tpdflatex refman" << endl << endl;
<< "\t$(LATEX_CMD) refman" << endl << endl;
}

t << endl
Expand All @@ -356,7 +360,7 @@ static void writeMakeBat()
#if defined(_MSC_VER)
QCString dir=Config_getString(LATEX_OUTPUT);
QCString fileName=dir+"/make.bat";
QCString latex_command = Config_getString(LATEX_CMD_NAME);
QCString latex_command = theTranslator->latexCommandName();
QCString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME);
QFile file(fileName);
bool generateBib = !Doxygen::citeDict->isEmpty();
Expand All @@ -371,14 +375,15 @@ static void writeMakeBat()
t << "del /s /f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf\n\n";
if (!Config_getBool(USE_PDFLATEX)) // use plain old latex
{
t << latex_command << " refman.tex\n";
t << "set LATEX_CMD=" << latex_command << "\n";
t << "%LATEX_CMD% refman.tex\n";
t << "echo ----\n";
t << mkidx_command << " refman.idx\n";
if (generateBib)
{
t << "bibtex refman\n";
t << "echo ----\n";
t << latex_command << " refman.tex\n";
t << "\t%LATEX_CMD% refman.tex\n";
}
t << "setlocal enabledelayedexpansion\n";
t << "set count=8\n";
Expand All @@ -390,28 +395,29 @@ static void writeMakeBat()
t << "set /a count-=1\n";
t << "if !count! EQU 0 goto :skip\n\n";
t << "echo ----\n";
t << latex_command << " refman.tex\n";
t << "%LATEX_CMD% refman.tex\n";
t << "goto :repeat\n";
t << ":skip\n";
t << "endlocal\n";
t << mkidx_command << " refman.idx\n";
t << latex_command << " refman.tex\n";
t << "%LATEX_CMD% refman.tex\n";
t << "dvips -o refman.ps refman.dvi\n";
t << "gswin32c -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "
"-sOutputFile=refman.pdf -c save pop -f refman.ps\n";
}
else // use pdflatex
{
t << "pdflatex refman\n";
t << "set LATEX_CMD=" << latex_command << "\n";
t << "%LATEX_CMD% refman\n";
t << "echo ----\n";
t << mkidx_command << " refman.idx\n";
if (generateBib)
{
t << "bibtex refman" << endl;
t << "pdflatex refman" << endl;
t << "%LATEX_CMD% refman" << endl;
}
t << "echo ----\n";
t << "pdflatex refman\n\n";
t << "%LATEX_CMD% refman\n\n";
t << "setlocal enabledelayedexpansion\n";
t << "set count=8\n";
t << ":repeat\n";
Expand All @@ -422,12 +428,12 @@ static void writeMakeBat()
t << "set /a count-=1\n";
t << "if !count! EQU 0 goto :skip\n\n";
t << "echo ----\n";
t << "pdflatex refman\n";
t << "%LATEX_CMD% refman\n";
t << "goto :repeat\n";
t << ":skip\n";
t << "endlocal\n";
t << mkidx_command << " refman.idx\n";
t << "pdflatex refman\n";
t << "%LATEX_CMD% refman\n";
t << "cd /D %Dir_Old%\n";
t << "set Dir_Old=\n";
}
Expand Down Expand Up @@ -504,6 +510,7 @@ static void writeDefaultHeaderPart1(FTextStream &t)
"\\usepackage{textcomp}\n"
"\\usepackage[nointegrals]{wasysym}\n"
"\\usepackage[table]{xcolor}\n"
"\\usepackage{ifpdf,ifxetex}\n"
"\n";

// Language support
Expand All @@ -516,9 +523,13 @@ static void writeDefaultHeaderPart1(FTextStream &t)
}

// Define default fonts
t << "% Font selection\n"
"\\usepackage[T1]{fontenc}\n"
"\\usepackage[scaled=.90]{helvet}\n"
t << "% Font selection\n";
QCString fontenc = theTranslator->latexFontenc();
if (!fontenc.isEmpty())
{
t << "\\usepackage[" << fontenc << "]{fontenc}\n";
}
t << "\\usepackage[scaled=.90]{helvet}\n"
"\\usepackage{courier}\n"
"\\usepackage{amssymb}\n"
"\\usepackage{sectsty}\n"
Expand Down Expand Up @@ -626,11 +637,14 @@ static void writeDefaultHeaderPart1(FTextStream &t)
if (pdfHyperlinks)
{
t << "% Hyperlinks (required, but should be loaded last)\n"
"\\usepackage{ifpdf}\n"
"\\ifpdf\n"
" \\usepackage[pdftex,pagebackref=true]{hyperref}\n"
"\\else\n"
" \\usepackage[ps2pdf,pagebackref=true]{hyperref}\n"
" \\ifxetex\n"
" \\usepackage[pagebackref=true]{hyperref}\n"
" \\else\n"
" \\usepackage[ps2pdf,pagebackref=true]{hyperref}\n"
" \\fi\n"
"\\fi\n"
"\\hypersetup{%\n"
" colorlinks=true,%\n"
Expand All @@ -656,8 +670,11 @@ static void writeDefaultHeaderPart1(FTextStream &t)
t << "%===== C O N T E N T S =====\n"
"\n"
"\\begin{document}\n";
if (theTranslator->idLanguage()=="greek")
t << "\\selectlanguage{greek}\n";
QCString documentPre = theTranslator->latexDocumentPre();
if (!documentPre.isEmpty())
{
t << documentPre;
}
t << "\n";

// Front matter
Expand Down Expand Up @@ -750,8 +767,13 @@ static void writeDefaultFooter(FTextStream &t)
"\\clearemptydoublepage\n"
"\\addcontentsline{toc}{" << unit << "}{" << theTranslator->trRTFGeneralIndex() << "}\n"
"\\printindex\n"
"\n"
"\\end{document}\n";
"\n";
QCString documentPost = theTranslator->latexDocumentPost();
if (!documentPost.isEmpty())
{
t << documentPost;
}
t << "\\end{document}\n";
}

void LatexGenerator::writeHeaderFile(QFile &f)
Expand Down
2 changes: 1 addition & 1 deletion src/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

#include "layout.h"
#include "message.h"
#include "config.h"
#include "language.h"
#include "vhdldocgen.h"
#include "util.h"
#include "doxygen.h"
#include "version.h"
#include "config.h"

#include <assert.h>
#include <qxml.h>
Expand Down
Loading

0 comments on commit 66a728c

Please sign in to comment.