1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
2002-03-21 17:27:08 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 the LyX Team.
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
1999-11-09 23:52:04 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
2001-12-28 13:26:54 +00:00
|
|
|
#pragma implementation
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyx_sty.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "bufferparams.h"
|
2000-12-29 12:48:02 +00:00
|
|
|
#include "FloatList.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
#include "language.h"
|
2001-11-19 15:34:11 +00:00
|
|
|
#include "encoding.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
#include "LString.h"
|
2000-12-29 12:48:02 +00:00
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/lstrings.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
using lyx::textclass_type;
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
using std::endl;
|
2002-07-21 22:17:21 +00:00
|
|
|
using std::list;
|
2001-12-28 13:26:54 +00:00
|
|
|
using std::set;
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::find;
|
|
|
|
using std::ostream;
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
LaTeXFeatures::LaTeXFeatures(BufferParams const & p)
|
|
|
|
: params(p)
|
2001-11-29 17:12:21 +00:00
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
|
|
|
void LaTeXFeatures::require(string const & name)
|
|
|
|
{
|
2002-01-10 10:05:45 +00:00
|
|
|
if (isRequired(name))
|
|
|
|
return;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-02-28 14:06:24 +00:00
|
|
|
features.push_back(name);
|
2001-11-19 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2002-07-20 20:47:54 +00:00
|
|
|
void LaTeXFeatures::useLayout(string const & layoutname)
|
2001-11-19 15:34:11 +00:00
|
|
|
{
|
2002-07-20 20:47:54 +00:00
|
|
|
// Some code to avoid loops in dependency definition
|
|
|
|
static int level = 0;
|
|
|
|
const int maxlevel = 30;
|
|
|
|
if (level > maxlevel) {
|
|
|
|
lyxerr << "LaTeXFeatures::useLayout: maximum level of "
|
|
|
|
<< "recursion attained by layout "
|
|
|
|
<< layoutname << endl;
|
|
|
|
return;
|
|
|
|
}
|
2002-09-06 14:51:39 +00:00
|
|
|
|
|
|
|
LyXTextClass const & tclass = params.getLyXTextClass();
|
2002-07-20 20:47:54 +00:00
|
|
|
if (tclass.hasLayout(layoutname)) {
|
|
|
|
// Is this layout already in usedLayouts?
|
2002-07-21 21:21:06 +00:00
|
|
|
list<string>::const_iterator cit = usedLayouts.begin();
|
|
|
|
list<string>::const_iterator end = usedLayouts.end();
|
2002-07-20 20:47:54 +00:00
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
if (layoutname == *cit)
|
|
|
|
return;
|
|
|
|
}
|
2002-09-06 14:51:39 +00:00
|
|
|
|
|
|
|
LyXLayout_ptr const & lyt = tclass[layoutname];
|
2002-07-20 20:47:54 +00:00
|
|
|
if (!lyt->depends_on().empty()) {
|
|
|
|
++level;
|
|
|
|
useLayout(lyt->depends_on());
|
|
|
|
--level;
|
|
|
|
}
|
|
|
|
usedLayouts.push_back(layoutname);
|
|
|
|
} else {
|
|
|
|
lyxerr << "LaTeXFeatures::useLayout: layout `"
|
|
|
|
<< layoutname << "' does not exist in this class"
|
2002-09-06 14:51:39 +00:00
|
|
|
<< endl;
|
2002-07-20 20:47:54 +00:00
|
|
|
}
|
2002-09-06 14:51:39 +00:00
|
|
|
|
2002-07-20 20:47:54 +00:00
|
|
|
--level;
|
2001-11-19 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
bool LaTeXFeatures::isRequired(string const & name) const
|
|
|
|
{
|
2002-03-21 17:27:08 +00:00
|
|
|
FeaturesList::const_iterator i = find(features.begin(),
|
2002-02-16 15:59:55 +00:00
|
|
|
features.end(),
|
|
|
|
name);
|
2001-11-29 17:12:21 +00:00
|
|
|
return i != features.end();
|
2001-11-19 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
void LaTeXFeatures::addExternalPreamble(string const & pream)
|
|
|
|
{
|
|
|
|
externalPreambles += pream;
|
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
void LaTeXFeatures::useFloat(string const & name)
|
|
|
|
{
|
|
|
|
usedFloats.insert(name);
|
2002-01-10 10:05:45 +00:00
|
|
|
// We only need float.sty if we use non builtin floats, or if we
|
|
|
|
// use the "H" modifier. This includes modified table and
|
|
|
|
// figure floats. (Lgb)
|
2002-08-27 15:51:19 +00:00
|
|
|
Floating const & fl = params.getLyXTextClass().floats().getType(name);
|
2002-01-10 10:05:45 +00:00
|
|
|
if (!fl.type().empty() && !fl.builtin()) {
|
|
|
|
require("float");
|
|
|
|
}
|
2001-11-19 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
void LaTeXFeatures::useLanguage(Language const * lang)
|
|
|
|
{
|
|
|
|
UsedLanguages.insert(lang);
|
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
void LaTeXFeatures::includeFile(string const & key, string const & name)
|
2001-11-19 15:34:11 +00:00
|
|
|
{
|
|
|
|
IncludedFiles[key] = name;
|
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
bool LaTeXFeatures::hasLanguages()
|
2001-11-19 15:34:11 +00:00
|
|
|
{
|
|
|
|
return !UsedLanguages.empty();
|
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
string LaTeXFeatures::getLanguages() const
|
2001-11-19 15:34:11 +00:00
|
|
|
{
|
|
|
|
ostringstream languages;
|
|
|
|
|
|
|
|
for (LanguageList::const_iterator cit =
|
|
|
|
UsedLanguages.begin();
|
2002-03-21 17:27:08 +00:00
|
|
|
cit != UsedLanguages.end();
|
2001-11-19 15:34:11 +00:00
|
|
|
++cit)
|
|
|
|
languages << (*cit)->babel() << ',';
|
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
return STRCONV(languages.str());
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding)
|
2001-11-19 15:34:11 +00:00
|
|
|
{
|
|
|
|
set<string> encodings;
|
|
|
|
for (LanguageList::const_iterator it =
|
|
|
|
UsedLanguages.begin();
|
|
|
|
it != UsedLanguages.end(); ++it)
|
|
|
|
if ((*it)->encoding()->LatexName() != doc_encoding)
|
|
|
|
encodings.insert((*it)->encoding()->LatexName());
|
|
|
|
return encodings;
|
|
|
|
}
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2002-01-10 10:05:45 +00:00
|
|
|
namespace {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-01-10 10:05:45 +00:00
|
|
|
char const * simplefeatures[] = {
|
|
|
|
"array",
|
|
|
|
"verbatim",
|
|
|
|
"longtable",
|
|
|
|
"rotating",
|
|
|
|
"latexsym",
|
|
|
|
"pifont",
|
|
|
|
"subfigure",
|
|
|
|
"floatflt",
|
|
|
|
"varioref",
|
|
|
|
"prettyref",
|
2002-07-09 13:38:27 +00:00
|
|
|
"float",
|
|
|
|
"wasy"
|
2002-01-10 10:05:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const int nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
|
|
|
|
|
|
|
|
}
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
string const LaTeXFeatures::getPackages() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-05-08 17:08:44 +00:00
|
|
|
ostringstream packages;
|
2002-07-21 21:21:06 +00:00
|
|
|
LyXTextClass const & tclass = params.getLyXTextClass();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
|
2002-07-09 13:38:27 +00:00
|
|
|
//
|
|
|
|
// These are all the 'simple' includes. i.e
|
|
|
|
// packages which we just \usepackage{package}
|
|
|
|
//
|
|
|
|
for (int i = 0; i < nb_simplefeatures; ++i) {
|
2002-01-10 10:05:45 +00:00
|
|
|
if (isRequired(simplefeatures[i]))
|
|
|
|
packages << "\\usepackage{"
|
2002-09-06 14:51:39 +00:00
|
|
|
<< simplefeatures[i] << "}\n";
|
2002-01-10 10:05:45 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-07-09 13:38:27 +00:00
|
|
|
//
|
|
|
|
// The rest of these packages are somewhat more complicated
|
|
|
|
// than those above.
|
|
|
|
//
|
2001-11-19 15:34:11 +00:00
|
|
|
|
2002-01-10 10:05:45 +00:00
|
|
|
if (isRequired("amsmath")
|
|
|
|
&& ! tclass.provides(LyXTextClass::amsmath)) {
|
|
|
|
packages << "\\usepackage{amsmath}\n";
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// color.sty
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("color")) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (params.graphicsDriver == "default")
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\usepackage{color}\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
2002-03-21 17:27:08 +00:00
|
|
|
packages << "\\usepackage["
|
2001-05-08 17:08:44 +00:00
|
|
|
<< params.graphicsDriver
|
|
|
|
<< "]{color}\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// makeidx.sty
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("makeidx")) {
|
2001-10-04 13:00:25 +00:00
|
|
|
if (! tclass.provides(LyXTextClass::makeidx))
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\usepackage{makeidx}\n";
|
|
|
|
packages << "\\makeindex\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
// graphicx.sty
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("graphicx") && params.graphicsDriver != "none") {
|
2000-07-31 12:30:10 +00:00
|
|
|
if (params.graphicsDriver == "default")
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\usepackage{graphicx}\n";
|
2000-07-31 12:30:10 +00:00
|
|
|
else
|
2002-03-21 17:27:08 +00:00
|
|
|
packages << "\\usepackage["
|
2001-05-08 17:08:44 +00:00
|
|
|
<< params.graphicsDriver
|
|
|
|
<< "]{graphicx}\n";
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
2001-05-10 15:53:10 +00:00
|
|
|
//if (algorithm) {
|
|
|
|
// packages << "\\usepackage{algorithm}\n";
|
|
|
|
//}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-10-31 15:19:49 +00:00
|
|
|
// lyxskak.sty --- newer chess support based on skak.sty
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("chess")) {
|
2001-10-31 15:19:49 +00:00
|
|
|
packages << "\\usepackage[ps,mover]{lyxskak}\n";
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// setspace.sty
|
2000-04-11 22:55:29 +00:00
|
|
|
if ((params.spacing.getSpace() != Spacing::Single
|
|
|
|
&& !params.spacing.isDefault())
|
2001-11-19 15:34:11 +00:00
|
|
|
|| isRequired("setspace")) {
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\usepackage{setspace}\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
switch (params.spacing.getSpace()) {
|
2000-04-11 22:55:29 +00:00
|
|
|
case Spacing::Default:
|
1999-09-27 18:44:28 +00:00
|
|
|
case Spacing::Single:
|
|
|
|
// we dont use setspace.sty so dont print anything
|
|
|
|
//packages += "\\singlespacing\n";
|
|
|
|
break;
|
|
|
|
case Spacing::Onehalf:
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\onehalfspacing\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
case Spacing::Double:
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\doublespacing\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
case Spacing::Other:
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\setstretch{"
|
|
|
|
<< params.spacing.getValue() << "}\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// amssymb.sty
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("amssymb") || params.use_amsmath)
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\usepackage{amssymb}\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
// url.sty
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("url") && ! tclass.provides(LyXTextClass::url))
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
|
1999-09-27 18:44:28 +00:00
|
|
|
" {\\newcommand{\\url}{\\texttt}}\n";
|
2000-05-19 16:46:01 +00:00
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
// float.sty
|
2001-07-19 14:12:37 +00:00
|
|
|
// natbib.sty
|
2002-04-23 22:34:24 +00:00
|
|
|
if (isRequired("natbib") && ! tclass.provides(LyXTextClass::natbib)) {
|
2001-07-26 09:47:36 +00:00
|
|
|
packages << "\\usepackage[";
|
|
|
|
if (params.use_numerical_citations) {
|
|
|
|
packages << "numbers";
|
|
|
|
} else {
|
|
|
|
packages << "authoryear";
|
|
|
|
}
|
|
|
|
packages << "]{natbib}\n";
|
2001-07-19 14:12:37 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << externalPreambles;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
return STRCONV(packages.str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
string const LaTeXFeatures::getMacros() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-05-08 17:08:44 +00:00
|
|
|
ostringstream macros;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-20 16:42:15 +00:00
|
|
|
if (isRequired("LyX"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << lyx_def << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
if (isRequired("lyxline"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << lyxline_def << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
if (isRequired("noun"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << noun_def << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
if (isRequired("lyxarrow"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << lyxarrow_def << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
// quotes.
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("quotesinglbase"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << quotesinglbase_def << '\n';
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("quotedblbase"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << quotedblbase_def << '\n';
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("guilsinglleft"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << guilsinglleft_def << '\n';
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("guilsinglright"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << guilsinglright_def << '\n';
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("guillemotleft"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << guillemotleft_def << '\n';
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("guillemotright"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << guillemotright_def << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
// Math mode
|
2002-01-10 10:05:45 +00:00
|
|
|
if (isRequired("boldsymbol") && !isRequired("amsmath"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << boldsymbol_def << '\n';
|
2002-01-10 10:05:45 +00:00
|
|
|
if (isRequired("binom") && !isRequired("amsmath"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << binom_def << '\n';
|
2002-03-04 11:10:26 +00:00
|
|
|
if (isRequired("mathcircumflex"))
|
|
|
|
macros << mathcircumflex_def << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// other
|
2001-11-29 17:12:21 +00:00
|
|
|
if (isRequired("NeedLyXMinipageIndent"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << minipageindent_def;
|
2002-05-08 12:58:16 +00:00
|
|
|
if (isRequired("ParagraphLeftIndent"))
|
|
|
|
macros << paragraphleftindent_def;
|
2002-03-21 17:27:08 +00:00
|
|
|
if (isRequired("NeedLyXFootnoteCode"))
|
2001-05-08 17:08:44 +00:00
|
|
|
macros << floatingfootnote_def;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-09-06 13:41:19 +00:00
|
|
|
// some problems with tex->html converters
|
|
|
|
if (isRequired("NeedTabularnewline"))
|
|
|
|
macros << tabularnewline_def;
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
// floats
|
2001-05-08 17:08:44 +00:00
|
|
|
getFloatDefinitions(macros);
|
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
return STRCONV(macros.str());
|
2002-05-10 12:58:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const LaTeXFeatures::getBabelOptions() const
|
|
|
|
{
|
|
|
|
ostringstream tmp;
|
|
|
|
|
2001-01-20 14:16:01 +00:00
|
|
|
for (LanguageList::const_iterator cit = UsedLanguages.begin();
|
|
|
|
cit != UsedLanguages.end(); ++cit)
|
|
|
|
if (!(*cit)->latex_options().empty())
|
2002-05-10 12:58:07 +00:00
|
|
|
tmp << (*cit)->latex_options() << '\n';
|
2001-01-20 14:16:01 +00:00
|
|
|
if (!params.language->latex_options().empty())
|
2002-05-10 12:58:07 +00:00
|
|
|
tmp << params.language->latex_options() << '\n';
|
2001-01-20 14:16:01 +00:00
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
return STRCONV(tmp.str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
string const LaTeXFeatures::getTClassPreamble() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-03-21 17:27:08 +00:00
|
|
|
// the text class specific preamble
|
2002-07-21 21:21:06 +00:00
|
|
|
LyXTextClass const & tclass = params.getLyXTextClass();
|
2001-05-08 17:08:44 +00:00
|
|
|
ostringstream tcpreamble;
|
2002-01-29 09:38:09 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
tcpreamble << tclass.preamble();
|
1999-11-04 01:40:20 +00:00
|
|
|
|
2002-07-21 21:21:06 +00:00
|
|
|
list<string>::const_iterator cit = usedLayouts.begin();
|
|
|
|
list<string>::const_iterator end = usedLayouts.end();
|
2002-03-02 16:39:54 +00:00
|
|
|
for (; cit != end; ++cit) {
|
2002-06-24 20:28:12 +00:00
|
|
|
tcpreamble << tclass[*cit]->preamble();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
return STRCONV(tcpreamble.str());
|
2002-03-21 17:27:08 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-10-23 09:42:14 +00:00
|
|
|
string const LaTeXFeatures::getLyXSGMLEntities() const
|
|
|
|
{
|
|
|
|
// Definition of entities used in the document that are LyX related.
|
|
|
|
ostringstream entities;
|
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
if (isRequired("lyxarrow")) {
|
2001-11-29 17:12:21 +00:00
|
|
|
entities << "<!ENTITY lyxarrow \"->\">" << '\n';
|
2001-10-23 09:42:14 +00:00
|
|
|
}
|
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
return STRCONV(entities.str());
|
2001-10-23 09:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
string const LaTeXFeatures::getIncludedFiles(string const & fname) const
|
2000-07-01 12:54:45 +00:00
|
|
|
{
|
2001-05-08 17:08:44 +00:00
|
|
|
ostringstream sgmlpreamble;
|
|
|
|
string const basename = OnlyPath(fname);
|
2000-11-13 15:43:36 +00:00
|
|
|
|
2000-08-03 21:17:52 +00:00
|
|
|
FileMap::const_iterator end = IncludedFiles.end();
|
2000-10-11 21:06:43 +00:00
|
|
|
for (FileMap::const_iterator fi = IncludedFiles.begin();
|
|
|
|
fi != end; ++fi)
|
2001-05-08 17:08:44 +00:00
|
|
|
sgmlpreamble << "\n<!ENTITY " << fi->first
|
2002-02-16 15:59:55 +00:00
|
|
|
<< (IsSGMLFilename(fi->second) ? " SYSTEM \"" : " \"")
|
2001-05-09 09:14:50 +00:00
|
|
|
<< MakeRelPath(fi->second, basename) << "\">";
|
2000-07-01 12:54:45 +00:00
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
return STRCONV(sgmlpreamble.str());
|
2000-07-01 12:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-09 09:14:50 +00:00
|
|
|
void LaTeXFeatures::showStruct() const {
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr << "LyX needs the following commands when LaTeXing:"
|
2000-04-10 21:40:13 +00:00
|
|
|
<< "\n***** Packages:" << getPackages()
|
|
|
|
<< "\n***** Macros:" << getMacros()
|
|
|
|
<< "\n***** Textclass stuff:" << getTClassPreamble()
|
1999-10-07 18:44:17 +00:00
|
|
|
<< "\n***** done." << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-04-10 21:40:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
BufferParams const & LaTeXFeatures::bufferParams() const
|
|
|
|
{
|
|
|
|
return params;
|
|
|
|
}
|
2001-05-08 17:08:44 +00:00
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
void LaTeXFeatures::getFloatDefinitions(ostream & os) const
|
2001-05-08 17:08:44 +00:00
|
|
|
{
|
2002-08-27 15:51:19 +00:00
|
|
|
FloatList const & floats = params.getLyXTextClass().floats();
|
2002-09-06 14:51:39 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
// Here we will output the code to create the needed float styles.
|
|
|
|
// We will try to do this as minimal as possible.
|
|
|
|
// \floatstyle{ruled}
|
|
|
|
// \newfloat{algorithm}{htbp}{loa}
|
|
|
|
// \floatname{algorithm}{Algorithm}
|
|
|
|
UsedFloats::const_iterator cit = usedFloats.begin();
|
|
|
|
UsedFloats::const_iterator end = usedFloats.end();
|
|
|
|
// ostringstream floats;
|
|
|
|
for (; cit != end; ++cit) {
|
2002-08-27 15:51:19 +00:00
|
|
|
Floating const & fl = floats.getType((*cit));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
// For builtin floats we do nothing.
|
|
|
|
if (fl.builtin()) continue;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
// We have to special case "table" and "figure"
|
|
|
|
if (fl.type() == "tabular" || fl.type() == "figure") {
|
|
|
|
// Output code to modify "table" or "figure"
|
|
|
|
// but only if builtin == false
|
|
|
|
// and that have to be true at this point in the
|
|
|
|
// function.
|
|
|
|
string const type = fl.type();
|
|
|
|
string const placement = fl.placement();
|
|
|
|
string const style = fl.style();
|
|
|
|
if (!style.empty()) {
|
|
|
|
os << "\\floatstyle{" << style << "}\n"
|
|
|
|
<< "\\restylefloat{" << type << "}\n";
|
|
|
|
}
|
|
|
|
if (!placement.empty()) {
|
|
|
|
os << "\\floatplacement{" << type << "}{"
|
|
|
|
<< placement << "}\n";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// The other non builtin floats.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
string const type = fl.type();
|
|
|
|
string const placement = fl.placement();
|
|
|
|
string const ext = fl.ext();
|
|
|
|
string const within = fl.within();
|
|
|
|
string const style = fl.style();
|
|
|
|
string const name = fl.name();
|
|
|
|
os << "\\floatstyle{" << style << "}\n"
|
|
|
|
<< "\\newfloat{" << type << "}{" << placement
|
2002-11-27 10:30:28 +00:00
|
|
|
<< "}{" << ext << '}';
|
2001-05-08 17:08:44 +00:00
|
|
|
if (!within.empty())
|
2002-11-27 10:30:28 +00:00
|
|
|
os << '[' << within << ']';
|
|
|
|
os << '\n'
|
2001-05-08 17:08:44 +00:00
|
|
|
<< "\\floatname{" << type << "}{"
|
|
|
|
<< name << "}\n";
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
// What missing here is to code to minimalize the code
|
2002-01-10 10:05:45 +00:00
|
|
|
// output so that the same floatstyle will not be
|
2001-11-09 13:44:48 +00:00
|
|
|
// used several times, when the same style is still in
|
2001-05-08 17:08:44 +00:00
|
|
|
// effect. (Lgb)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|