Skip to content

Commit

Permalink
Unify handling of extra packages in formula.cpp and latexgen.cpp so f…
Browse files Browse the repository at this point in the history
…ormula.cpp handles package arguments correctly
  • Loading branch information
Thadeus Fleming authored and Dimitri van Heesch committed May 20, 2016
1 parent 14b04be commit 4d2e203
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
7 changes: 1 addition & 6 deletions src/formula.cpp
Expand Up @@ -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;
Expand Down
16 changes: 1 addition & 15 deletions src/latexgen.cpp
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions src/util.cpp
Expand Up @@ -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";
}
}

1 change: 1 addition & 0 deletions src/util.h
Expand Up @@ -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.