Permalink
Browse files

Unify handling of extra packages in formula.cpp and latexgen.cpp so f…

…ormula.cpp handles package arguments correctly
  • Loading branch information...
Thadeus Fleming Dimitri van Heesch
Thadeus Fleming authored and Dimitri van Heesch committed May 20, 2016
1 parent 14b04be commit 4d2e203a55a2af8f15a3933b86201e6e9b6901b3
Showing with 23 additions and 21 deletions.
  1. +1 −6 src/formula.cpp
  2. +1 −15 src/latexgen.cpp
  3. +20 −0 src/util.cpp
  4. +1 −0 src/util.h
@@ -70,12 +70,7 @@ void FormulaList::generateBitmaps(const char *path)
if (Config_getBool(LATEX_BATCHMODE)) t << "\\batchmode" << endl;
t << "\\documentclass{article}" << endl;
t << "\\usepackage{epsfig}" << endl; // for those who want to include images
const char *s=Config_getList(EXTRA_PACKAGES).first();
while (s)
{
t << "\\usepackage{" << s << "}\n";
s=Config_getList(EXTRA_PACKAGES).next();
}
writeExtraLatexPackages(t);
t << "\\pagestyle{empty}" << endl;
t << "\\begin{document}" << endl;
int page=0;
@@ -619,21 +619,7 @@ static void writeDefaultHeaderPart1(FTextStream &t)
"\\makeindex\n"
"\n";
// User-specified packages
QStrList &extraPackages = Config_getList(EXTRA_PACKAGES);
if (!extraPackages.isEmpty()) {
t << "% Packages requested by user\n";
const char *pkgName=extraPackages.first();
while (pkgName)
{
if ((pkgName[0] == '[') || (pkgName[0] == '{'))
t << "\\usepackage" << pkgName << "\n";
else
t << "\\usepackage{" << pkgName << "}\n";
pkgName=extraPackages.next();
}
t << "\n";
}
writeExtraLatexPackages(t);
// Hyperlinks
bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
@@ -8679,3 +8679,23 @@ bool openOutputFile(const char *outFile,QFile &f)
return fileOpened;
}
void writeExtraLatexPackages(FTextStream &t)
{
// User-specified packages
QStrList &extraPackages = Config_getList(EXTRA_PACKAGES);
if (!extraPackages.isEmpty())
{
t << "% Packages requested by user\n";
const char *pkgName=extraPackages.first();
while (pkgName)
{
if ((pkgName[0] == '[') || (pkgName[0] == '{'))
t << "\\usepackage" << pkgName << "\n";
else
t << "\\usepackage{" << pkgName << "}\n";
pkgName=extraPackages.next();
}
t << "\n";
}
}
@@ -475,6 +475,7 @@ void convertProtectionLevel(
bool mainPageHasTitle();
bool openOutputFile(const char *outFile,QFile &f);
void writeExtraLatexPackages(FTextStream &t);
#endif

0 comments on commit 4d2e203

Please sign in to comment.