void BufferParams::validate(LaTeXFeatures & features) const
{
+ features.require(getTextClass().requires());
+
if (outputChanges) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
bool xcolorsoul = LaTeXFeatures::isAvailable("soul") &&
if (use_esint == package_on)
features.require("esint");
+ // Document-level line spacing
+ if (spacing().getSpace() != Spacing::Single && !spacing().isDefault())
+ features.require("setspace");
+
// the bullet shapes are buffer level not paragraph level
// so they are tested here
for (int i = 0; i < 4; ++i) {
features.require("pifont");
}
}
+
+ if (pdfoptions().use_hyperref)
+ features.require("hyperref");
}
// The optional packages;
docstring lyxpreamble(from_ascii(features.getPackages()));
+ // Line spacing
+ lyxpreamble += from_utf8(spacing().writePreamble(tclass.provides("SetSpace")));
+
// We try to load babel late, in case it interferes
// with other packages. But some packages also need babel to be loaded
// before, e.g. jurabib has to be called after babel.
// before hyperref. Then hyperref has a chance to detect babel.
// * Has to be loaded before the "LyX specific LaTeX commands" to
// avoid errors with algorithm floats.
- odocstringstream oss;
// use hyperref explicitely when it is required
- pdfoptions().writeLaTeX(oss, features.isRequired("hyperref"));
- lyxpreamble += oss.str();
+ if (features.isRequired("hyperref")) {
+ odocstringstream oss;
+ pdfoptions().writeLaTeX(oss, getTextClass().provides("hyperref"));
+ lyxpreamble += oss.str();
+ }
// this might be useful...
lyxpreamble += "\n\\makeatletter\n";
"may not be possible.\n"), from_utf8(modName));
frontend::Alert::warning(_("Package not available"), msg);
}
- FileName layout_file = libFileSearch("layouts", lm->filename);
+ FileName layout_file = libFileSearch("layouts", lm->getFilename());
textClass_->read(layout_file, TextClass::MODULE);
}
}
}
-string const BufferParams::paperSizeName() const
+string const BufferParams::paperSizeName(Papersize_Purpose const & purpose) const
{
char real_papersize = papersize;
if (real_papersize == PAPER_DEFAULT)
real_papersize = lyxrc.default_papersize;
switch (real_papersize) {
+ case PAPER_DEFAULT:
+ // could be anything, so don't guess
+ return string();
+ case PAPER_CUSTOM: {
+ if (purpose == XDVI && !paperwidth.empty() &&
+ !paperheight.empty()) {
+ // heightxwidth<unit>
+ string first = paperwidth;
+ string second = paperheight;
+ if (orientation == ORIENTATION_LANDSCAPE)
+ first.swap(second);
+ // cut off unit.
+ return first.erase(first.length() - 2)
+ + "x" + second;
+ }
+ return string();
+ }
case PAPER_A3:
return "a3";
case PAPER_A4:
return "a4";
case PAPER_A5:
return "a5";
+ case PAPER_B3:
+ // dvips and dvipdfm do not know this
+ if (purpose == DVIPS || purpose == DVIPDFM)
+ return string();
+ return "b3";
+ case PAPER_B4:
+ // dvipdfm does not know this
+ if (purpose == DVIPDFM)
+ return string();
+ return "b4";
case PAPER_B5:
+ // dvipdfm does not know this
+ if (purpose == DVIPDFM)
+ return string();
return "b5";
case PAPER_USEXECUTIVE:
+ // dvipdfm does not know this
+ if (purpose == DVIPDFM)
+ return string();
return "foolscap";
case PAPER_USLEGAL:
return "legal";
case PAPER_USLETTER:
default:
+ if (purpose == XDVI)
+ return "us";
return "letter";
}
}
result += ' ' + paperwidth;
result += ',' + paperheight;
} else {
- string const paper_option = paperSizeName();
- if (paper_option != "letter" ||
- orientation != ORIENTATION_LANDSCAPE) {
+ string const paper_option = paperSizeName(DVIPS);
+ if (!paper_option.empty() && (paper_option != "letter" ||
+ orientation != ORIENTATION_LANDSCAPE)) {
// dvips won't accept -t letter -t landscape.
// In all other cases, include the paper size
// explicitly.