Skip to content

Commit

Permalink
Bug 687576 - Add support for LATEX_EXTRA_STYLESHEET
Browse files Browse the repository at this point in the history
Added the possibility for  LATEX_EXTRA_STYLESHEET analogous to  HTML_EXTRA_STYLESHEET. Special attention has been paid to the extension as ".sty" is automatically added by the \usepackage
  • Loading branch information
albert-github committed Nov 29, 2014
1 parent 200b828 commit fd91442
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 10 deletions.
23 changes: 18 additions & 5 deletions src/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1797,13 +1797,13 @@ doxygen -w html new_header.html new_footer.html new_stylesheet.css YourConfigFil
since it does not replace the standard style sheet and is therefore more
robust against future updates. Doxygen will copy the style sheet files to
the output directory.
\note The order of the extra stylesheet files is of importance (e.g. the last
stylesheet in the list overrules the setting of the previous ones in the list).
\note The order of the extra style sheet files is of importance (e.g. the last
style sheet in the list overrules the setting of the previous ones in the list).
]]>
</docs>
<docs doxywizard='0' doxyfile='0'>
<![CDATA[
Here is an example stylesheet that gives the contents area a fixed width:
Here is an example style sheet that gives the contents area a fixed width:
\verbatim
body {
background-color: #CCC;
Expand Down Expand Up @@ -1858,7 +1858,7 @@ hr.footer {
<docs>
<![CDATA[
The \c HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
Doxygen will adjust the colors in the stylesheet and background images
Doxygen will adjust the colors in the style sheet and background images
according to this color. Hue is specified as an angle on a colorwheel,
see http://en.wikipedia.org/wiki/Hue for more information.
For instance the value 0 represents red, 60 is yellow, 120 is green,
Expand Down Expand Up @@ -2173,7 +2173,7 @@ The \c DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
Windows users are probably better off using the HTML help feature.
Via custom stylesheets (see \ref cfg_html_extra_stylesheet "HTML_EXTRA_STYLESHEET")
Via custom style sheets (see \ref cfg_html_extra_stylesheet "HTML_EXTRA_STYLESHEET")
one can further \ref doxygen_finetune "fine-tune" the look of the index.
As an example, the default style sheet generated by doxygen has an
example that shows how to put an image at the root of the tree instead of
Expand Down Expand Up @@ -2534,6 +2534,19 @@ EXTRA_PACKAGES=times
used inside the footer.
<br>Note: Only use a user-defined footer if you know what you are doing!
]]>
</docs>
</option>
<option type='list' id='LATEX_EXTRA_STYLESHEET' format='file' defval='' depends='GENERATE_LATEX'>
<docs>
<![CDATA[
The \c LATEX_EXTRA_STYLESHEET tag can be used to specify additional
user-defined \f$\mbox{\LaTeX}\f$ style sheets that are included after the standard
style sheets created by doxygen. Using this option one can overrule
certain style aspects. Doxygen will copy the style sheet files to
the output directory.
\note The order of the extra style sheet files is of importance (e.g. the last
style sheet in the list overrules the setting of the previous ones in the list).
]]>
</docs>
</option>
Expand Down
28 changes: 28 additions & 0 deletions src/doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9161,6 +9161,33 @@ static void readTagFile(Entry *root,const char *tl)
parseTagFile(root,fi.absFilePath().utf8());
}

//----------------------------------------------------------------------------
static void copyLatexStyleSheet()
{
QStrList latexExtraStyleSheet = Config_getList("LATEX_EXTRA_STYLESHEET");
for (uint i=0; i<latexExtraStyleSheet.count(); ++i)
{
QCString fileName(latexExtraStyleSheet.at(i));
if (!fileName.isEmpty())
{
QFileInfo fi(fileName);
if (!fi.exists())
{
err("Style sheet '%s' specified by LATEX_EXTRA_STYLESHEET does not exist!\n",fileName.data());
}
else
{
QCString destFileName = Config_getString("LATEX_OUTPUT")+"/"+fi.fileName().data();
if (!checkExtension(fi.fileName().data(), latexStyleExtension))
{
destFileName += latexStyleExtension;
}
copyFile(fileName, destFileName);
}
}
}
}

//----------------------------------------------------------------------------
static void copyStyleSheet()
{
Expand Down Expand Up @@ -11365,6 +11392,7 @@ void generateOutput()
g_outputList->add(new LatexGenerator);
LatexGenerator::init();

copyLatexStyleSheet();
// copy static stuff
copyExtraFiles("LATEX_EXTRA_FILES","LATEX_OUTPUT");
}
Expand Down
25 changes: 23 additions & 2 deletions src/latexgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,29 @@ static void writeDefaultHeaderPart1(FTextStream &t)
t << "% Packages required by doxygen\n"
"\\usepackage{fixltx2e}\n" // for \textsubscript
"\\usepackage{calc}\n"
"\\usepackage{doxygen}\n"
"\\usepackage{graphicx}\n"
"\\usepackage{doxygen}\n";
QStrList extraLatexStyle = Config_getList("LATEX_EXTRA_STYLESHEET");
for (uint i=0; i<extraLatexStyle.count(); ++i)
{
QCString fileName(extraLatexStyle.at(i));
if (!fileName.isEmpty())
{
QFileInfo fi(fileName);
if (fi.exists())
{
if (checkExtension(fi.fileName().data(), latexStyleExtension))
{
// strip the extension, it will be added by the usepackage in the tex conversion process
t << "\\usepackage{" << stripExtensionGeneral(fi.fileName().data(), latexStyleExtension) << "}\n";
}
else
{
t << "\\usepackage{" << fi.fileName().utf8() << "}\n";
}
}
}
}
t << "\\usepackage{graphicx}\n"
"\\usepackage[utf8]{inputenc}\n"
"\\usepackage{makeidx}\n"
"\\usepackage{multicol}\n"
Expand Down
2 changes: 2 additions & 0 deletions src/latexgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

class QFile;

static const char *latexStyleExtension = ".sty";

/** Generator for LaTeX output. */
class LatexGenerator : public OutputGenerator
{
Expand Down
20 changes: 17 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6559,16 +6559,30 @@ QCString rtfFormatBmkStr(const char *name)
return *tag;
}

QCString stripExtension(const char *fName)
bool checkExtension(const char *fName, const char *ext)
{
return (QCString(fName).right(QCString(ext).length())==ext);
}

//QCString stripExtension(const char *fName, const char *ext)
QCString stripExtensionGeneral(const char *fName, const char *ext)
{
QCString result=fName;
if (result.right(Doxygen::htmlFileExtension.length())==Doxygen::htmlFileExtension)
//if (result.right(Doxygen::htmlFileExtension.length())==Doxygen::htmlFileExtension)
//{
//result=result.left(result.length()-Doxygen::htmlFileExtension.length());
//}
if (result.right(QCString(ext).length())==QCString(ext))
{
result=result.left(result.length()-Doxygen::htmlFileExtension.length());
result=result.left(result.length()-QCString(ext).length());
}
return result;
}

QCString stripExtension(const char *fName)
{
return stripExtensionGeneral(fName, Doxygen::htmlFileExtension);
}

void replaceNamespaceAliases(QCString &scope,int i)
{
Expand Down
4 changes: 4 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ QCString rtfFormatBmkStr(const char *name);

QCString linkToText(SrcLangExt lang,const char *link,bool isFileName);

bool checkExtension(const char *fName, const char *ext);

QCString stripExtensionGeneral(const char *fName, const char *ext);

QCString stripExtension(const char *fName);

void replaceNamespaceAliases(QCString &scope,int i);
Expand Down

0 comments on commit fd91442

Please sign in to comment.