2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file LaTeXFeatures.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Jos<EFBFBD> Matos
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
|
#include "BufferParams.h"
|
2009-03-17 13:23:54 +00:00
|
|
|
|
#include "ColorSet.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Encoding.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "Floating.h"
|
2000-12-29 12:48:02 +00:00
|
|
|
|
#include "FloatList.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Language.h"
|
2007-09-29 20:02:32 +00:00
|
|
|
|
#include "Layout.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXRC.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
|
#include "TextClass.h"
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
2008-02-01 15:54:40 +00:00
|
|
|
|
#include "support/debug.h"
|
2006-10-21 19:40:29 +00:00
|
|
|
|
#include "support/docstream.h"
|
2007-12-17 16:04:46 +00:00
|
|
|
|
#include "support/FileName.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include "support/filetools.h"
|
2008-02-01 15:54:40 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
|
using namespace lyx::support;
|
2007-07-17 17:46:54 +00:00
|
|
|
|
|
2008-03-15 00:22:54 +00:00
|
|
|
|
|
2007-07-17 17:46:54 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2007-04-30 20:20:05 +00:00
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Strings
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//\NeedsTeXFormat{LaTeX2e}
|
|
|
|
|
//\ProvidesPackage{lyx}[1996/01/11 LLE v0.2 (LyX LaTeX Extensions)]
|
|
|
|
|
//\message{LyX LaTeX Extensions (LLE v0.2) of 11-Jan-1996.}
|
|
|
|
|
|
|
|
|
|
static string const lyx_def =
|
|
|
|
|
"\\providecommand{\\LyX}{L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}";
|
|
|
|
|
|
|
|
|
|
static string const lyxline_def =
|
|
|
|
|
"\\newcommand{\\lyxline}[1][1pt]{%\n"
|
|
|
|
|
" \\par\\noindent%\n"
|
|
|
|
|
" \\rule[.5ex]{\\linewidth}{#1}\\par}";
|
|
|
|
|
|
|
|
|
|
static string const noun_def = "\\newcommand{\\noun}[1]{\\textsc{#1}}";
|
|
|
|
|
|
|
|
|
|
static string const lyxarrow_def =
|
2009-01-18 14:01:12 +00:00
|
|
|
|
"\\DeclareRobustCommand*{\\lyxarrow}{%\n"
|
2009-01-11 08:37:11 +00:00
|
|
|
|
"\\@ifstar\n"
|
|
|
|
|
"{\\leavevmode\\,$\\triangleleft$\\,\\allowbreak}\n"
|
|
|
|
|
"{\\leavevmode\\,$\\triangleright$\\,\\allowbreak}}";
|
2007-04-30 20:20:05 +00:00
|
|
|
|
|
|
|
|
|
// for quotes without babel. This does not give perfect results, but
|
|
|
|
|
// anybody serious about non-english quotes should use babel (JMarc).
|
|
|
|
|
|
|
|
|
|
static string const quotedblbase_def =
|
|
|
|
|
"\\ProvideTextCommandDefault{\\quotedblbase}{%\n"
|
|
|
|
|
" \\raisebox{-1.4ex}[1ex][.5ex]{\\textquotedblright}%\n"
|
|
|
|
|
" \\penalty10000\\hskip0em\\relax%\n"
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
static string const quotesinglbase_def =
|
|
|
|
|
"\\ProvideTextCommandDefault{\\quotesinglbase}{%\n"
|
|
|
|
|
" \\raisebox{-1.4ex}[1ex][.5ex]{\\textquoteright}%\n"
|
|
|
|
|
" \\penalty10000\\hskip0em\\relax%\n"
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
static string const guillemotleft_def =
|
|
|
|
|
"\\ProvideTextCommandDefault{\\guillemotleft}{%\n"
|
|
|
|
|
" {\\usefont{U}{lasy}{m}{n}\\char'50\\kern-.15em\\char'50}%\n"
|
|
|
|
|
"\\penalty10000\\hskip0pt\\relax%\n"
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
static string const guillemotright_def =
|
|
|
|
|
"\\ProvideTextCommandDefault{\\guillemotright}{%\n"
|
|
|
|
|
" \\penalty10000\\hskip0pt%\n"
|
|
|
|
|
" {\\usefont{U}{lasy}{m}{n}\\char'51\\kern-.15em\\char'51}%\n"
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
static string const guilsinglleft_def =
|
|
|
|
|
"\\ProvideTextCommandDefault{\\guilsinglleft}{%\n"
|
|
|
|
|
" {\\usefont{U}{lasy}{m}{n}\\char'50}%\n"
|
|
|
|
|
" \\penalty10000\\hskip0pt\\relax%\n"
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
static string const guilsinglright_def =
|
|
|
|
|
"\\ProvideTextCommandDefault{\\guilsinglright}{%\n"
|
|
|
|
|
" \\penalty10000\\hskip0pt%\n"
|
|
|
|
|
" {\\usefont{U}{lasy}{m}{n}\\char'51}%\n"
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
static string const paragraphleftindent_def =
|
|
|
|
|
"\\newenvironment{LyXParagraphLeftIndent}[1]%\n"
|
|
|
|
|
"{\n"
|
|
|
|
|
" \\begin{list}{}{%\n"
|
|
|
|
|
" \\setlength{\\topsep}{0pt}%\n"
|
|
|
|
|
" \\addtolength{\\leftmargin}{#1}\n"
|
|
|
|
|
// ho hum, yet more things commented out with no hint as to why they
|
|
|
|
|
// weren't just removed
|
|
|
|
|
// "%% \\addtolength{\\leftmargin}{#1\\textwidth}\n"
|
|
|
|
|
// "%% \\setlength{\\textwidth}{#2\\textwidth}\n"
|
|
|
|
|
// "%% \\setlength\\listparindent\\parindent%\n"
|
|
|
|
|
// "%% \\setlength\\itemindent\\parindent%\n"
|
|
|
|
|
" \\setlength{\\parsep}{0pt plus 1pt}%\n"
|
|
|
|
|
" }\n"
|
|
|
|
|
" \\item[]\n"
|
|
|
|
|
"}\n"
|
|
|
|
|
"{\\end{list}}\n";
|
|
|
|
|
|
|
|
|
|
static string const floatingfootnote_def =
|
|
|
|
|
"%% Special footnote code from the package 'stblftnt.sty'\n"
|
|
|
|
|
"%% Author: Robin Fairbairns -- Last revised Dec 13 1996\n"
|
|
|
|
|
"\\let\\SF@@footnote\\footnote\n"
|
|
|
|
|
"\\def\\footnote{\\ifx\\protect\\@typeset@protect\n"
|
|
|
|
|
" \\expandafter\\SF@@footnote\n"
|
|
|
|
|
" \\else\n"
|
|
|
|
|
" \\expandafter\\SF@gobble@opt\n"
|
|
|
|
|
" \\fi\n"
|
|
|
|
|
"}\n"
|
|
|
|
|
"\\expandafter\\def\\csname SF@gobble@opt \\endcsname{\\@ifnextchar[%]\n"
|
|
|
|
|
" \\SF@gobble@twobracket\n"
|
|
|
|
|
" \\@gobble\n"
|
|
|
|
|
"}\n"
|
|
|
|
|
"\\edef\\SF@gobble@opt{\\noexpand\\protect\n"
|
|
|
|
|
" \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n"
|
|
|
|
|
"\\def\\SF@gobble@twobracket[#1]#2{}\n";
|
|
|
|
|
|
|
|
|
|
static string const binom_def =
|
|
|
|
|
"%% Binom macro for standard LaTeX users\n"
|
|
|
|
|
"\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n";
|
|
|
|
|
|
|
|
|
|
static string const mathcircumflex_def =
|
|
|
|
|
"%% For printing a cirumflex inside a formula\n"
|
|
|
|
|
"\\newcommand{\\mathcircumflex}[0]{\\mbox{\\^{}}}\n";
|
|
|
|
|
|
|
|
|
|
static string const tabularnewline_def =
|
|
|
|
|
"%% Because html converters don't know tabularnewline\n"
|
|
|
|
|
"\\providecommand{\\tabularnewline}{\\\\}\n";
|
2007-12-23 16:32:00 +00:00
|
|
|
|
|
2007-04-30 20:20:05 +00:00
|
|
|
|
static string const lyxgreyedout_def =
|
|
|
|
|
"%% The greyedout annotation environment\n"
|
|
|
|
|
"\\newenvironment{lyxgreyedout}{\\textcolor[gray]{0.8}\\bgroup}{\\egroup}\n";
|
|
|
|
|
|
|
|
|
|
// We want to omit the file extension for includegraphics, but this does not
|
|
|
|
|
// work when the filename contains other dots.
|
|
|
|
|
// Idea from http://www.tex.ac.uk/cgi-bin/texfaq2html?label=unkgrfextn
|
|
|
|
|
static string const lyxdot_def =
|
|
|
|
|
"%% A simple dot to overcome graphicx limitations\n"
|
|
|
|
|
"\\newcommand{\\lyxdot}{.}\n";
|
|
|
|
|
|
2007-05-08 17:46:03 +00:00
|
|
|
|
static string const changetracking_dvipost_def =
|
|
|
|
|
"%% Change tracking with dvipost\n"
|
|
|
|
|
"\\dvipostlayout\n"
|
|
|
|
|
"\\dvipost{osstart color push Red}\n"
|
|
|
|
|
"\\dvipost{osend color pop}\n"
|
|
|
|
|
"\\dvipost{cbstart color push Blue}\n"
|
|
|
|
|
"\\dvipost{cbend color pop}\n"
|
2007-05-13 15:17:57 +00:00
|
|
|
|
"\\newcommand{\\lyxadded}[3]{\\changestart#3\\changeend}\n"
|
2007-05-08 17:46:03 +00:00
|
|
|
|
"\\newcommand{\\lyxdeleted}[3]{%\n"
|
|
|
|
|
"\\changestart\\overstrikeon#3\\overstrikeoff\\changeend}\n";
|
|
|
|
|
|
2009-01-12 08:03:06 +00:00
|
|
|
|
static string const changetracking_xcolor_ulem_def =
|
|
|
|
|
"%% Change tracking with ulem\n"
|
2008-01-19 11:17:12 +00:00
|
|
|
|
"\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}#3}}\n"
|
2009-01-12 08:03:06 +00:00
|
|
|
|
"\\newcommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\sout{#3}}}\n";
|
2008-01-19 11:17:12 +00:00
|
|
|
|
|
2009-01-12 08:03:06 +00:00
|
|
|
|
static string const changetracking_xcolor_ulem_hyperref_def =
|
|
|
|
|
"%% Change tracking with ulem\n"
|
2008-01-19 11:17:12 +00:00
|
|
|
|
"\\newcommand{\\lyxadded}[3]{{\\texorpdfstring{\\color{lyxadded}}{}#3}}\n"
|
2009-01-12 08:03:06 +00:00
|
|
|
|
"\\newcommand{\\lyxdeleted}[3]{{\\texorpdfstring{\\color{lyxdeleted}\\sout{#3}}{}}}\n";
|
2008-01-19 11:17:12 +00:00
|
|
|
|
|
2007-05-08 17:46:03 +00:00
|
|
|
|
static string const changetracking_none_def =
|
2007-05-13 15:17:57 +00:00
|
|
|
|
"\\newcommand{\\lyxadded}[3]{#3}\n"
|
|
|
|
|
"\\newcommand{\\lyxdeleted}[3]{}\n";
|
2007-04-30 20:20:05 +00:00
|
|
|
|
|
2007-10-12 18:21:51 +00:00
|
|
|
|
static string const textgreek_def =
|
|
|
|
|
"\\DeclareRobustCommand{\\greektext}{%\n"
|
2008-09-26 15:53:15 +00:00
|
|
|
|
" \\fontencoding{LGR}\\selectfont\\def\\encodingdefault{LGR}}\n"
|
2007-10-12 18:21:51 +00:00
|
|
|
|
"\\DeclareRobustCommand{\\textgreek}[1]{\\leavevmode{\\greektext #1}}\n"
|
|
|
|
|
"\\DeclareFontEncoding{LGR}{}{}\n";
|
|
|
|
|
|
|
|
|
|
static string const textcyr_def =
|
|
|
|
|
"\\DeclareRobustCommand{\\cyrtext}{%\n"
|
2008-09-26 15:53:15 +00:00
|
|
|
|
" \\fontencoding{T2A}\\selectfont\\def\\encodingdefault{T2A}}\n"
|
2007-10-12 18:21:51 +00:00
|
|
|
|
"\\DeclareRobustCommand{\\textcyr}[1]{\\leavevmode{\\cyrtext #1}}\n"
|
2008-09-26 00:21:35 +00:00
|
|
|
|
"\\AtBeginDocument{\\DeclareFontEncoding{T2A}{}{}}\n";
|
2008-05-31 20:54:50 +00:00
|
|
|
|
|
2008-06-01 14:11:36 +00:00
|
|
|
|
static string const lyxmathsym_def =
|
2009-03-31 11:29:31 +00:00
|
|
|
|
"\\newcommand{\\lyxmathsym}[1]{\\ifmmode\\begingroup\\def\\b@ld{bold}\n"
|
|
|
|
|
" \\text{\\ifx\\math@version\\b@ld\\bfseries\\fi#1}\\endgroup\\else#1\\fi}\n";
|
2008-05-31 20:54:50 +00:00
|
|
|
|
|
2008-07-01 12:46:46 +00:00
|
|
|
|
static string const papersizedvi_def =
|
|
|
|
|
"\\special{papersize=\\the\\paperwidth,\\the\\paperheight}\n";
|
|
|
|
|
|
|
|
|
|
static string const papersizepdf_def =
|
|
|
|
|
"\\pdfpageheight\\paperheight\n"
|
|
|
|
|
"\\pdfpagewidth\\paperwidth\n";
|
|
|
|
|
|
2008-09-26 15:53:15 +00:00
|
|
|
|
static string const cedilla_def =
|
|
|
|
|
"\\newcommand{\\docedilla}[2]{\\underaccent{#1\\mathchar'30}{#2}}\n"
|
|
|
|
|
"\\newcommand{\\cedilla}[1]{\\mathpalette\\docedilla{#1}}\n";
|
|
|
|
|
|
|
|
|
|
static string const subring_def =
|
|
|
|
|
"\\newcommand{\\dosubring}[2]{\\underaccent{#1\\mathchar'27}{#2}}\n"
|
|
|
|
|
"\\newcommand{\\subring}[1]{\\mathpalette\\dosubring{#1}}\n";
|
|
|
|
|
|
|
|
|
|
static string const subdot_def =
|
|
|
|
|
"\\newcommand{\\dosubdot}[2]{\\underaccent{#1.}{#2}}\n"
|
|
|
|
|
"\\newcommand{\\subdot}[1]{\\mathpalette\\dosubdot{#1}}\n";
|
|
|
|
|
|
|
|
|
|
static string const subhat_def =
|
|
|
|
|
"\\newcommand{\\dosubhat}[2]{\\underaccent{#1\\mathchar'136}{#2}}\n"
|
|
|
|
|
"\\newcommand{\\subhat}[1]{\\mathpalette\\dosubhat{#1}}\n";
|
|
|
|
|
|
|
|
|
|
static string const subtilde_def =
|
|
|
|
|
"\\newcommand{\\dosubtilde}[2]{\\underaccent{#1\\mathchar'176}{#2}}\n"
|
|
|
|
|
"\\newcommand{\\subtilde}[1]{\\mathpalette\\dosubtilde{#1}}\n";
|
|
|
|
|
|
|
|
|
|
static string const dacute_def =
|
|
|
|
|
"\\DeclareMathAccent{\\dacute}{\\mathalpha}{operators}{'175}\n";
|
|
|
|
|
|
|
|
|
|
static string const tipasymb_def =
|
|
|
|
|
"\\DeclareFontEncoding{T3}{}{}\n"
|
|
|
|
|
"\\DeclareSymbolFont{tipasymb}{T3}{cmr}{m}{n}\n";
|
|
|
|
|
|
|
|
|
|
static string const dgrave_def =
|
|
|
|
|
"\\DeclareMathAccent{\\dgrave}{\\mathord}{tipasymb}{'15}\n";
|
|
|
|
|
|
|
|
|
|
static string const rcap_def =
|
|
|
|
|
"\\DeclareMathAccent{\\rcap}{\\mathord}{tipasymb}{'20}\n";
|
|
|
|
|
|
|
|
|
|
static string const ogonek_def =
|
|
|
|
|
"\\newcommand{\\doogonek}[2]{\\setbox0=\\hbox{$#1#2$}\\underaccent{#1\\mkern-6mu\n"
|
|
|
|
|
" \\ifx#2O\\hskip0.5\\wd0\\else\\ifx#2U\\hskip0.5\\wd0\\else\\hskip\\wd0\\fi\\fi\n"
|
|
|
|
|
" \\ifx#2o\\mkern-2mu\\else\\ifx#2e\\mkern-1mu\\fi\\fi\n"
|
|
|
|
|
" \\mathchar\"0\\hexnumber@\\symtipasymb0C}{#2}}\n"
|
|
|
|
|
"\\newcommand{\\ogonek}[1]{\\mathpalette\\doogonek{#1}}\n";
|
|
|
|
|
|
2007-04-30 20:20:05 +00:00
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// LaTeXFeatures
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-02-01 15:12:04 +00:00
|
|
|
|
LaTeXFeatures::Packages LaTeXFeatures::packages_;
|
2005-01-24 17:12:19 +00:00
|
|
|
|
|
|
|
|
|
|
2006-03-28 18:49:46 +00:00
|
|
|
|
LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
OutputParams const & r)
|
2009-02-07 12:28:04 +00:00
|
|
|
|
: buffer_(&b), params_(p), runparams_(r), in_float_(false)
|
2001-11-29 17:12:21 +00:00
|
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
|
2003-05-23 11:18:43 +00:00
|
|
|
|
bool LaTeXFeatures::useBabel() const
|
|
|
|
|
{
|
|
|
|
|
return lyxrc.language_use_babel ||
|
2007-05-05 19:18:34 +00:00
|
|
|
|
(bufferParams().language->lang() != lyxrc.default_language &&
|
|
|
|
|
!bufferParams().language->babel().empty()) ||
|
2003-05-23 11:18:43 +00:00
|
|
|
|
this->hasLanguages();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
void LaTeXFeatures::require(string const & name)
|
|
|
|
|
{
|
2008-02-01 15:12:04 +00:00
|
|
|
|
features_.insert(name);
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2008-02-01 15:12:04 +00:00
|
|
|
|
void LaTeXFeatures::require(set<string> const & names)
|
|
|
|
|
{
|
|
|
|
|
features_.insert(names.begin(), names.end());
|
2001-11-19 15:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
|
2005-01-24 17:12:19 +00:00
|
|
|
|
void LaTeXFeatures::getAvailable()
|
|
|
|
|
{
|
2008-04-02 23:06:22 +00:00
|
|
|
|
Lexer lex;
|
2006-11-26 21:30:39 +00:00
|
|
|
|
support::FileName const real_file = libFileSearch("", "packages.lst");
|
2005-01-24 17:12:19 +00:00
|
|
|
|
|
|
|
|
|
if (real_file.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
lex.setFile(real_file);
|
|
|
|
|
|
2005-04-26 11:12:20 +00:00
|
|
|
|
if (!lex.isOK())
|
2005-01-24 17:12:19 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2005-01-28 14:50:23 +00:00
|
|
|
|
// Make sure that we are clean
|
|
|
|
|
packages_.clear();
|
2005-04-26 11:12:20 +00:00
|
|
|
|
|
2005-01-24 17:12:19 +00:00
|
|
|
|
bool finished = false;
|
|
|
|
|
// Parse config-file
|
|
|
|
|
while (lex.isOK() && !finished) {
|
|
|
|
|
switch (lex.lex()) {
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_FEOF:
|
2005-01-24 17:12:19 +00:00
|
|
|
|
finished = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2008-02-01 15:12:04 +00:00
|
|
|
|
packages_.insert(lex.getString());
|
2005-01-24 17:12:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-07-11 13:39:08 +00:00
|
|
|
|
void LaTeXFeatures::useLayout(docstring 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 "
|
2007-07-11 13:39:08 +00:00
|
|
|
|
<< to_utf8(layoutname) << endl;
|
2002-07-20 20:47:54 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2002-09-06 14:51:39 +00:00
|
|
|
|
|
2008-02-28 01:42:02 +00:00
|
|
|
|
DocumentClass const & tclass = params_.documentClass();
|
2002-07-20 20:47:54 +00:00
|
|
|
|
if (tclass.hasLayout(layoutname)) {
|
|
|
|
|
// Is this layout already in usedLayouts?
|
2008-02-01 15:12:04 +00:00
|
|
|
|
if (find(usedLayouts_.begin(), usedLayouts_.end(), layoutname)
|
|
|
|
|
!= usedLayouts_.end())
|
|
|
|
|
return;
|
|
|
|
|
|
2008-03-06 20:01:30 +00:00
|
|
|
|
Layout const & layout = tclass[layoutname];
|
2008-02-01 15:12:04 +00:00
|
|
|
|
require(layout.requires());
|
2002-09-06 14:51:39 +00:00
|
|
|
|
|
2008-02-01 15:12:04 +00:00
|
|
|
|
if (!layout.depends_on().empty()) {
|
2002-07-20 20:47:54 +00:00
|
|
|
|
++level;
|
2008-02-01 15:12:04 +00:00
|
|
|
|
useLayout(layout.depends_on());
|
2002-07-20 20:47:54 +00:00
|
|
|
|
--level;
|
|
|
|
|
}
|
2003-09-18 14:01:02 +00:00
|
|
|
|
usedLayouts_.push_back(layoutname);
|
2002-07-20 20:47:54 +00:00
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "LaTeXFeatures::useLayout: layout `"
|
2007-07-11 13:39:08 +00:00
|
|
|
|
<< to_utf8(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
|
|
|
|
|
{
|
2008-02-01 15:12:04 +00:00
|
|
|
|
return features_.find(name) != features_.end();
|
2001-11-19 15:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
bool LaTeXFeatures::mustProvide(string const & name) const
|
|
|
|
|
{
|
2008-02-28 01:42:02 +00:00
|
|
|
|
return isRequired(name) && !params_.documentClass().provides(name);
|
2007-04-06 09:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-08 13:35:04 +00:00
|
|
|
|
bool LaTeXFeatures::isAvailable(string const & name)
|
2005-01-24 17:12:19 +00:00
|
|
|
|
{
|
|
|
|
|
if (packages_.empty())
|
|
|
|
|
getAvailable();
|
2008-02-01 15:54:40 +00:00
|
|
|
|
string n = name;
|
|
|
|
|
if (suffixIs(n, ".sty"))
|
|
|
|
|
n.erase(name.length() - 4);
|
|
|
|
|
return packages_.find(n) != packages_.end();
|
2005-01-24 17:12:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-20 17:08:39 +00:00
|
|
|
|
void LaTeXFeatures::addPreambleSnippet(string const & preamble)
|
2001-11-19 15:34:11 +00:00
|
|
|
|
{
|
2008-02-01 15:12:04 +00:00
|
|
|
|
SnippetList::const_iterator begin = preamble_snippets_.begin();
|
|
|
|
|
SnippetList::const_iterator end = preamble_snippets_.end();
|
2003-09-04 01:49:21 +00:00
|
|
|
|
if (find(begin, end, preamble) == end)
|
2003-09-18 14:01:02 +00:00
|
|
|
|
preamble_snippets_.push_back(preamble);
|
2001-11-19 15:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
|
2008-03-02 11:30:50 +00:00
|
|
|
|
void LaTeXFeatures::useFloat(string const & name, bool subfloat)
|
2001-11-19 15:34:11 +00:00
|
|
|
|
{
|
2008-03-02 11:30:50 +00:00
|
|
|
|
if (!usedFloats_[name])
|
|
|
|
|
usedFloats_[name] = subfloat;
|
|
|
|
|
if (subfloat)
|
|
|
|
|
require("subfig");
|
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)
|
2008-02-28 01:42:02 +00:00
|
|
|
|
Floating const & fl = params_.documentClass().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)
|
|
|
|
|
{
|
2007-05-05 19:18:34 +00:00
|
|
|
|
if (!lang->babel().empty())
|
|
|
|
|
UsedLanguages_.insert(lang);
|
2008-07-15 13:08:27 +00:00
|
|
|
|
if (lang->lang() == "vietnamese")
|
|
|
|
|
require("vietnamese");
|
2007-11-17 12:37:18 +00:00
|
|
|
|
// CJK languages do not have a babel name.
|
|
|
|
|
// They use the CJK package
|
|
|
|
|
if (lang->encoding()->package() == Encoding::CJK)
|
|
|
|
|
require("CJK");
|
2008-08-18 17:26:09 +00:00
|
|
|
|
// japanese package is special
|
|
|
|
|
if (lang->encoding()->package() == Encoding::japanese)
|
|
|
|
|
require("japanese");
|
2001-11-19 15:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
|
2006-10-21 19:40:29 +00:00
|
|
|
|
void LaTeXFeatures::includeFile(docstring const & key, string const & name)
|
2001-11-19 15:34:11 +00:00
|
|
|
|
{
|
2003-09-18 14:01:02 +00:00
|
|
|
|
IncludedFiles_[key] = name;
|
2001-11-19 15:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
|
2003-02-16 00:54:43 +00:00
|
|
|
|
bool LaTeXFeatures::hasLanguages() const
|
2001-11-19 15:34:11 +00:00
|
|
|
|
{
|
2003-09-18 14:01:02 +00:00
|
|
|
|
return !UsedLanguages_.empty();
|
2001-11-19 15:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
2007-05-06 20:26:02 +00:00
|
|
|
|
LanguageList::const_iterator const begin = UsedLanguages_.begin();
|
|
|
|
|
for (LanguageList::const_iterator cit = begin;
|
2003-09-18 14:01:02 +00:00
|
|
|
|
cit != UsedLanguages_.end();
|
2007-05-06 20:26:02 +00:00
|
|
|
|
++cit) {
|
|
|
|
|
if (cit != begin)
|
|
|
|
|
languages << ',';
|
|
|
|
|
languages << (*cit)->babel();
|
|
|
|
|
}
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return 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
|
|
|
|
|
2003-02-16 00:54:43 +00:00
|
|
|
|
set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding) const
|
2001-11-19 15:34:11 +00:00
|
|
|
|
{
|
2007-05-06 20:26:02 +00:00
|
|
|
|
// This does only find encodings of languages supported by babel, but
|
|
|
|
|
// that does not matter since we don't have a language with an
|
|
|
|
|
// encoding supported by inputenc but without babel support.
|
2001-11-19 15:34:11 +00:00
|
|
|
|
set<string> encodings;
|
2003-09-18 14:01:02 +00:00
|
|
|
|
LanguageList::const_iterator it = UsedLanguages_.begin();
|
|
|
|
|
LanguageList::const_iterator end = UsedLanguages_.end();
|
|
|
|
|
for (; it != end; ++it)
|
2006-12-28 18:15:25 +00:00
|
|
|
|
if ((*it)->encoding()->latexName() != doc_encoding &&
|
2008-08-18 17:26:09 +00:00
|
|
|
|
((*it)->encoding()->package() == Encoding::inputenc
|
|
|
|
|
|| (*it)->encoding()->package() == Encoding::japanese))
|
2006-04-09 00:26:19 +00:00
|
|
|
|
encodings.insert((*it)->encoding()->latexName());
|
2001-11-19 15:34:11 +00:00
|
|
|
|
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[] = {
|
2007-05-28 11:44:13 +00:00
|
|
|
|
// note that the package order here will be the same in the LaTeX-output
|
2002-01-10 10:05:45 +00:00
|
|
|
|
"array",
|
|
|
|
|
"verbatim",
|
|
|
|
|
"longtable",
|
|
|
|
|
"rotating",
|
|
|
|
|
"latexsym",
|
|
|
|
|
"pifont",
|
2008-05-13 01:23:50 +00:00
|
|
|
|
// subfig is handled in BufferParams.cpp
|
2002-01-10 10:05:45 +00:00
|
|
|
|
"varioref",
|
|
|
|
|
"prettyref",
|
2007-09-24 17:15:18 +00:00
|
|
|
|
/*For a successful cooperation of the `wrapfig' package with the
|
|
|
|
|
`float' package you should load the `wrapfig' package *after*
|
|
|
|
|
the `float' package. See the caption package documentation
|
|
|
|
|
for explanation.*/
|
2002-07-09 13:38:27 +00:00
|
|
|
|
"float",
|
2008-01-11 18:56:53 +00:00
|
|
|
|
"rotfloat",
|
2007-09-22 12:51:33 +00:00
|
|
|
|
"wrapfig",
|
2006-07-03 19:13:56 +00:00
|
|
|
|
"booktabs",
|
2003-10-07 07:42:15 +00:00
|
|
|
|
"dvipost",
|
|
|
|
|
"fancybox",
|
2004-03-07 14:33:17 +00:00
|
|
|
|
"calc",
|
2007-09-12 08:15:33 +00:00
|
|
|
|
"units",
|
2006-04-14 14:30:43 +00:00
|
|
|
|
"tipa",
|
2008-02-03 17:26:46 +00:00
|
|
|
|
"tipx",
|
2006-06-03 16:46:27 +00:00
|
|
|
|
"framed",
|
2007-05-13 15:17:57 +00:00
|
|
|
|
"soul",
|
2006-12-06 16:46:57 +00:00
|
|
|
|
"textcomp",
|
2007-05-28 11:44:13 +00:00
|
|
|
|
"pmboxdraw",
|
2007-05-28 16:04:01 +00:00
|
|
|
|
"bbding",
|
|
|
|
|
"ifsym",
|
|
|
|
|
"marvosym",
|
|
|
|
|
"txfonts",
|
2007-05-30 23:22:58 +00:00
|
|
|
|
"mathrsfs",
|
|
|
|
|
"ascii",
|
2007-10-13 19:18:36 +00:00
|
|
|
|
"url",
|
2008-01-07 16:59:10 +00:00
|
|
|
|
"covington",
|
|
|
|
|
"csquotes",
|
|
|
|
|
"enumitem",
|
2008-01-07 17:32:47 +00:00
|
|
|
|
"endnotes",
|
2008-01-10 04:14:22 +00:00
|
|
|
|
"ifthen",
|
2008-01-22 08:41:45 +00:00
|
|
|
|
"amsthm",
|
2008-09-08 21:51:38 +00:00
|
|
|
|
// listings is handled in BufferParams.cpp
|
2008-04-11 14:07:25 +00:00
|
|
|
|
"bm",
|
2008-06-01 04:46:50 +00:00
|
|
|
|
"pdfpages",
|
2008-09-26 15:53:15 +00:00
|
|
|
|
"amscd",
|
|
|
|
|
"slashed"
|
2002-01-10 10:05:45 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
|
2002-01-10 10:05:45 +00:00
|
|
|
|
|
|
|
|
|
}
|
2001-11-29 17:12:21 +00:00
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2008-09-29 19:18:00 +00:00
|
|
|
|
string const LaTeXFeatures::getColorOptions() const
|
|
|
|
|
{
|
|
|
|
|
ostringstream colors;
|
|
|
|
|
|
|
|
|
|
// Handling the color packages separately is needed to be able to load them
|
|
|
|
|
// before babel when hyperref is loaded with the colorlinks option
|
|
|
|
|
// for more info see Bufferparams.cpp
|
|
|
|
|
|
|
|
|
|
// [x]color.sty
|
|
|
|
|
if (mustProvide("color") || mustProvide("xcolor")) {
|
|
|
|
|
string const package =
|
|
|
|
|
(mustProvide("xcolor") ? "xcolor" : "color");
|
|
|
|
|
if (params_.graphicsDriver == "default"
|
|
|
|
|
|| params_.graphicsDriver == "none")
|
|
|
|
|
colors << "\\usepackage{" << package << "}\n";
|
|
|
|
|
else
|
|
|
|
|
colors << "\\usepackage["
|
|
|
|
|
<< params_.graphicsDriver
|
|
|
|
|
<< "]{" << package << "}\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// pdfcolmk must be loaded after color
|
|
|
|
|
if (mustProvide("pdfcolmk"))
|
|
|
|
|
colors << "\\usepackage{pdfcolmk}\n";
|
|
|
|
|
|
|
|
|
|
return colors.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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;
|
2008-02-28 01:42:02 +00:00
|
|
|
|
DocumentClass const & tclass = params_.documentClass();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2008-01-07 16:59:10 +00:00
|
|
|
|
// FIXME: currently, we can only load packages and macros known
|
|
|
|
|
// to LyX.
|
|
|
|
|
// However, with the Require tag of layouts/custom insets,
|
|
|
|
|
// also inknown packages can be requested. They are silently
|
|
|
|
|
// swallowed now. We should change this eventually.
|
|
|
|
|
|
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) {
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide(simplefeatures[i]))
|
2002-01-10 10:05:45 +00:00
|
|
|
|
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
|
|
|
|
|
2007-06-22 21:25:41 +00:00
|
|
|
|
// esint is preferred for esintoramsmath
|
2008-10-12 13:06:17 +00:00
|
|
|
|
if ((mustProvide("amsmath")
|
|
|
|
|
&& params_.use_amsmath != BufferParams::package_off)
|
|
|
|
|
|| (mustProvide("esintoramsmath")
|
|
|
|
|
&& params_.use_esint == BufferParams::package_off
|
|
|
|
|
&& params_.use_amsmath != BufferParams::package_off)) {
|
2002-01-10 10:05:45 +00:00
|
|
|
|
packages << "\\usepackage{amsmath}\n";
|
2009-03-31 11:29:31 +00:00
|
|
|
|
} else {
|
|
|
|
|
// amsbsy and amstext are already provided by amsmath
|
|
|
|
|
if (mustProvide("amsbsy"))
|
|
|
|
|
packages << "\\usepackage{amsbsy}\n";
|
|
|
|
|
if (mustProvide("amstext"))
|
|
|
|
|
packages << "\\usepackage{amstext}\n";
|
2002-01-10 10:05:45 +00:00
|
|
|
|
}
|
2008-01-10 04:14:22 +00:00
|
|
|
|
|
2005-06-11 11:02:22 +00:00
|
|
|
|
// wasysym is a simple feature, but it must be after amsmath if both
|
|
|
|
|
// are used
|
2006-11-13 17:35:18 +00:00
|
|
|
|
// wasysym redefines some integrals (e.g. iint) from amsmath. That
|
|
|
|
|
// leads to inconsistent integrals. We only load this package if
|
2007-06-18 18:21:29 +00:00
|
|
|
|
// the document does not contain integrals (then isRequired("esint")
|
|
|
|
|
// is false) or if esint is used, since esint redefines all relevant
|
|
|
|
|
// integral symbols from wasysym and amsmath.
|
2006-11-13 17:35:18 +00:00
|
|
|
|
// See http://bugzilla.lyx.org/show_bug.cgi?id=1942
|
2007-06-18 18:21:29 +00:00
|
|
|
|
if (mustProvide("wasysym") &&
|
|
|
|
|
(params_.use_esint != BufferParams::package_off || !isRequired("esint")))
|
2005-06-11 11:02:22 +00:00
|
|
|
|
packages << "\\usepackage{wasysym}\n";
|
|
|
|
|
|
2008-09-26 15:53:15 +00:00
|
|
|
|
// accents must be loaded after amsmath
|
|
|
|
|
if (mustProvide("accents"))
|
|
|
|
|
packages << "\\usepackage{accents}\n";
|
|
|
|
|
|
2008-09-29 19:18:00 +00:00
|
|
|
|
// [x]color and pdfcolmk are handled in getColorOptions() above
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// makeidx.sty
|
2001-11-19 15:34:11 +00:00
|
|
|
|
if (isRequired("makeidx")) {
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (!tclass.provides("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
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("graphicx") && params_.graphicsDriver != "none") {
|
2003-09-18 14:01:02 +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["
|
2003-09-18 14:01:02 +00:00
|
|
|
|
<< params_.graphicsDriver
|
2001-05-08 17:08:44 +00:00
|
|
|
|
<< "]{graphicx}\n";
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
2006-06-03 16:46:27 +00:00
|
|
|
|
// shadecolor for shaded
|
2007-12-04 10:27:27 +00:00
|
|
|
|
if (isRequired("framed") && mustProvide("color")) {
|
2007-11-02 23:42:27 +00:00
|
|
|
|
RGBColor c = rgbFromHexName(lcolor.getX11Name(Color_shadedbg));
|
2007-06-06 19:33:57 +00:00
|
|
|
|
//255.0 to force conversion to double
|
|
|
|
|
//NOTE As J<>rgen Spitzm<7A>ller pointed out, an alternative would be
|
|
|
|
|
//to use the xcolor package instead, and then we can do
|
|
|
|
|
// \define{shadcolor}{RGB}...
|
|
|
|
|
//and not do any conversion. We'd then need to require xcolor
|
|
|
|
|
//in InsetNote::validate().
|
|
|
|
|
int const stmSize = packages.precision(2);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
packages << "\\definecolor{shadecolor}{rgb}{"
|
2007-06-16 16:09:26 +00:00
|
|
|
|
<< c.r / 255.0 << ',' << c.g / 255.0 << ',' << c.b / 255.0 << "}\n";
|
2007-06-06 19:33:57 +00:00
|
|
|
|
packages.precision(stmSize);
|
2006-06-03 16:46:27 +00:00
|
|
|
|
}
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
2001-10-31 15:19:49 +00:00
|
|
|
|
// lyxskak.sty --- newer chess support based on skak.sty
|
2008-03-15 00:22:54 +00:00
|
|
|
|
if (mustProvide("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
|
2008-01-22 08:41:45 +00:00
|
|
|
|
if (mustProvide("setspace") && !tclass.provides("SetSpace"))
|
2008-08-19 07:06:51 +00:00
|
|
|
|
packages << "\\usepackage{setspace}\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// amssymb.sty
|
2007-05-28 22:27:45 +00:00
|
|
|
|
if (mustProvide("amssymb")
|
2007-04-06 09:02:23 +00:00
|
|
|
|
|| params_.use_amsmath == BufferParams::package_on)
|
2001-05-08 17:08:44 +00:00
|
|
|
|
packages << "\\usepackage{amssymb}\n";
|
2006-11-13 17:35:18 +00:00
|
|
|
|
|
|
|
|
|
// esint must be after amsmath and wasysym, since it will redeclare
|
|
|
|
|
// inconsistent integral symbols
|
2007-06-22 21:25:41 +00:00
|
|
|
|
if ((mustProvide("esint") || mustProvide("esintoramsmath")) &&
|
|
|
|
|
params_.use_esint != BufferParams::package_off)
|
2006-11-13 17:35:18 +00:00
|
|
|
|
packages << "\\usepackage{esint}\n";
|
|
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
|
// natbib.sty
|
2008-09-04 14:39:08 +00:00
|
|
|
|
// Some classes load natbib themselves, but still allow (or even require)
|
|
|
|
|
// plain numeric citations (ReVTeX is such a case, see bug 5182).
|
|
|
|
|
// This special case is indicated by the "natbib-internal" key.
|
2008-09-04 19:54:32 +00:00
|
|
|
|
if (mustProvide("natbib") && !tclass.provides("natbib-internal")) {
|
2001-07-26 09:47:36 +00:00
|
|
|
|
packages << "\\usepackage[";
|
2008-04-20 15:00:11 +00:00
|
|
|
|
if (params_.citeEngine() == ENGINE_NATBIB_NUMERICAL)
|
2001-07-26 09:47:36 +00:00
|
|
|
|
packages << "numbers";
|
2008-03-15 00:22:54 +00:00
|
|
|
|
else
|
2001-07-26 09:47:36 +00:00
|
|
|
|
packages << "authoryear";
|
|
|
|
|
packages << "]{natbib}\n";
|
2001-07-19 14:12:37 +00:00
|
|
|
|
}
|
2004-07-24 10:55:30 +00:00
|
|
|
|
|
2004-07-23 16:03:39 +00:00
|
|
|
|
// jurabib -- we need version 0.6 at least.
|
2008-03-15 00:22:54 +00:00
|
|
|
|
if (mustProvide("jurabib"))
|
2004-08-02 13:20:03 +00:00
|
|
|
|
packages << "\\usepackage{jurabib}[2004/01/25]\n";
|
2008-03-10 13:26:20 +00:00
|
|
|
|
|
|
|
|
|
// xargs -- we need version 1.09 at least
|
2008-03-15 00:22:54 +00:00
|
|
|
|
if (mustProvide("xargs"))
|
2008-03-10 13:26:20 +00:00
|
|
|
|
packages << "\\usepackage{xargs}[2008/03/08]\n";
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2004-03-29 13:17:25 +00:00
|
|
|
|
// bibtopic -- the dot provides the aux file naming which
|
|
|
|
|
// LyX can detect.
|
2008-03-15 00:22:54 +00:00
|
|
|
|
if (mustProvide("bibtopic"))
|
2004-03-29 13:17:25 +00:00
|
|
|
|
packages << "\\usepackage[dot]{bibtopic}\n";
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("xy"))
|
2006-10-31 19:10:30 +00:00
|
|
|
|
packages << "\\usepackage[all]{xy}\n";
|
|
|
|
|
|
2009-01-12 08:03:06 +00:00
|
|
|
|
if (mustProvide("ulem"))
|
|
|
|
|
packages << "\\PassOptionsToPackage{normalem}{ulem}\n"
|
|
|
|
|
"\\usepackage{ulem}\n";
|
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("nomencl")) {
|
2007-04-23 18:33:36 +00:00
|
|
|
|
// Make it work with the new and old version of the package,
|
|
|
|
|
// but don't use the compatibility option since it is
|
|
|
|
|
// incompatible to other packages.
|
|
|
|
|
packages << "\\usepackage{nomencl}\n"
|
2007-05-28 22:27:45 +00:00
|
|
|
|
"% the following is useful when we have the old nomencl.sty package\n"
|
|
|
|
|
"\\providecommand{\\printnomenclature}{\\printglossary}\n"
|
|
|
|
|
"\\providecommand{\\makenomenclature}{\\makeglossary}\n"
|
|
|
|
|
"\\makenomenclature\n";
|
2006-11-04 17:55:36 +00:00
|
|
|
|
}
|
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return 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
|
|
|
|
|
2003-09-18 14:01:02 +00:00
|
|
|
|
if (!preamble_snippets_.empty())
|
2003-09-04 17:01:00 +00:00
|
|
|
|
macros << '\n';
|
2008-02-01 15:12:04 +00:00
|
|
|
|
SnippetList::const_iterator pit = preamble_snippets_.begin();
|
|
|
|
|
SnippetList::const_iterator pend = preamble_snippets_.end();
|
2007-11-02 23:42:27 +00:00
|
|
|
|
for (; pit != pend; ++pit)
|
2003-09-04 17:01:00 +00:00
|
|
|
|
macros << *pit << '\n';
|
|
|
|
|
|
2008-07-01 12:46:46 +00:00
|
|
|
|
if (mustProvide("papersize"))
|
|
|
|
|
if (runparams_.flavor == OutputParams::LATEX)
|
|
|
|
|
macros << papersizedvi_def << '\n';
|
|
|
|
|
else
|
|
|
|
|
macros << papersizepdf_def << '\n';
|
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("LyX"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << lyx_def << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("lyxline"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << lyxline_def << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("noun"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << noun_def << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("lyxarrow"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << lyxarrow_def << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-10-12 18:21:51 +00:00
|
|
|
|
if (mustProvide("textgreek"))
|
|
|
|
|
macros << textgreek_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("textcyr"))
|
|
|
|
|
macros << textcyr_def << '\n';
|
|
|
|
|
|
2008-06-01 14:11:36 +00:00
|
|
|
|
if (mustProvide("lyxmathsym"))
|
|
|
|
|
macros << lyxmathsym_def << '\n';
|
2008-05-31 20:54:50 +00:00
|
|
|
|
|
2008-09-26 15:53:15 +00:00
|
|
|
|
if (mustProvide("cedilla"))
|
|
|
|
|
macros << cedilla_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("subring"))
|
|
|
|
|
macros << subring_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("subdot"))
|
|
|
|
|
macros << subdot_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("subhat"))
|
|
|
|
|
macros << subhat_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("subtilde"))
|
|
|
|
|
macros << subtilde_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("dacute"))
|
|
|
|
|
macros << dacute_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("tipasymb"))
|
|
|
|
|
macros << tipasymb_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("dgrave"))
|
|
|
|
|
macros << dgrave_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("rcap"))
|
|
|
|
|
macros << rcap_def << '\n';
|
|
|
|
|
|
|
|
|
|
if (mustProvide("ogonek"))
|
|
|
|
|
macros << ogonek_def << '\n';
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// quotes.
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("quotesinglbase"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << quotesinglbase_def << '\n';
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("quotedblbase"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << quotedblbase_def << '\n';
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("guilsinglleft"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << guilsinglleft_def << '\n';
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("guilsinglright"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << guilsinglright_def << '\n';
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("guillemotleft"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << guillemotleft_def << '\n';
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("guillemotright"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << guillemotright_def << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
// Math mode
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("binom") && !isRequired("amsmath"))
|
2001-05-08 17:08:44 +00:00
|
|
|
|
macros << binom_def << '\n';
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("mathcircumflex"))
|
2002-03-04 11:10:26 +00:00
|
|
|
|
macros << mathcircumflex_def << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// other
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("ParagraphLeftIndent"))
|
2002-05-08 12:58:16 +00:00
|
|
|
|
macros << paragraphleftindent_def;
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("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
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("NeedTabularnewline"))
|
2002-09-06 13:41:19 +00:00
|
|
|
|
macros << tabularnewline_def;
|
|
|
|
|
|
2003-07-29 12:20:04 +00:00
|
|
|
|
// greyedout environment (note inset)
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("lyxgreyedout"))
|
2003-07-29 12:20:04 +00:00
|
|
|
|
macros << lyxgreyedout_def;
|
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("lyxdot"))
|
2004-04-26 11:05:19 +00:00
|
|
|
|
macros << lyxdot_def << '\n';
|
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
// floats
|
2001-05-08 17:08:44 +00:00
|
|
|
|
getFloatDefinitions(macros);
|
|
|
|
|
|
2007-05-08 17:46:03 +00:00
|
|
|
|
// change tracking
|
2007-11-02 23:42:27 +00:00
|
|
|
|
if (mustProvide("ct-dvipost"))
|
2007-05-08 17:46:03 +00:00
|
|
|
|
macros << changetracking_dvipost_def;
|
2007-11-02 23:42:27 +00:00
|
|
|
|
|
2009-01-12 08:03:06 +00:00
|
|
|
|
if (mustProvide("ct-xcolor-ulem")) {
|
2007-06-16 16:09:26 +00:00
|
|
|
|
int const prec = macros.precision(2);
|
|
|
|
|
|
2007-11-02 23:42:27 +00:00
|
|
|
|
RGBColor cadd = rgbFromHexName(lcolor.getX11Name(Color_addedtext));
|
2007-05-28 22:27:45 +00:00
|
|
|
|
macros << "\\providecolor{lyxadded}{rgb}{"
|
2007-06-16 16:09:26 +00:00
|
|
|
|
<< cadd.r / 255.0 << ',' << cadd.g / 255.0 << ',' << cadd.b / 255.0 << "}\n";
|
2007-05-13 15:17:57 +00:00
|
|
|
|
|
2007-11-02 23:42:27 +00:00
|
|
|
|
RGBColor cdel = rgbFromHexName(lcolor.getX11Name(Color_deletedtext));
|
2007-05-28 22:27:45 +00:00
|
|
|
|
macros << "\\providecolor{lyxdeleted}{rgb}{"
|
2007-06-16 16:09:26 +00:00
|
|
|
|
<< cdel.r / 255.0 << ',' << cdel.g / 255.0 << ',' << cdel.b / 255.0 << "}\n";
|
|
|
|
|
|
|
|
|
|
macros.precision(prec);
|
2008-01-19 11:17:12 +00:00
|
|
|
|
|
2008-01-19 11:32:06 +00:00
|
|
|
|
if (isRequired("hyperref"))
|
2009-01-12 08:03:06 +00:00
|
|
|
|
macros << changetracking_xcolor_ulem_hyperref_def;
|
2008-01-19 11:17:12 +00:00
|
|
|
|
else
|
2009-01-12 08:03:06 +00:00
|
|
|
|
macros << changetracking_xcolor_ulem_def;
|
2007-05-13 15:17:57 +00:00
|
|
|
|
}
|
2007-11-02 23:42:27 +00:00
|
|
|
|
|
|
|
|
|
if (mustProvide("ct-none"))
|
2007-05-08 17:46:03 +00:00
|
|
|
|
macros << changetracking_none_def;
|
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return macros.str();
|
2002-05-10 12:58:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const LaTeXFeatures::getBabelOptions() const
|
|
|
|
|
{
|
|
|
|
|
ostringstream tmp;
|
|
|
|
|
|
2003-09-18 14:01:02 +00:00
|
|
|
|
LanguageList::const_iterator it = UsedLanguages_.begin();
|
|
|
|
|
LanguageList::const_iterator end = UsedLanguages_.end();
|
|
|
|
|
for (; it != end; ++it)
|
|
|
|
|
if (!(*it)->latex_options().empty())
|
|
|
|
|
tmp << (*it)->latex_options() << '\n';
|
|
|
|
|
if (!params_.language->latex_options().empty())
|
|
|
|
|
tmp << params_.language->latex_options() << '\n';
|
2001-01-20 14:16:01 +00:00
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return tmp.str();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-08 17:22:44 +00:00
|
|
|
|
docstring 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
|
2008-02-28 01:42:02 +00:00
|
|
|
|
DocumentClass const & tclass = params_.documentClass();
|
2006-11-08 17:22:44 +00:00
|
|
|
|
odocstringstream 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
|
|
|
|
|
2007-07-11 13:39:08 +00:00
|
|
|
|
list<docstring>::const_iterator cit = usedLayouts_.begin();
|
|
|
|
|
list<docstring>::const_iterator end = usedLayouts_.end();
|
2002-03-02 16:39:54 +00:00
|
|
|
|
for (; cit != end; ++cit) {
|
2008-03-06 20:01:30 +00:00
|
|
|
|
tcpreamble << tclass[*cit].preamble();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return tcpreamble.str();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 19:40:29 +00:00
|
|
|
|
docstring const LaTeXFeatures::getLyXSGMLEntities() const
|
2001-10-23 09:42:14 +00:00
|
|
|
|
{
|
|
|
|
|
// Definition of entities used in the document that are LyX related.
|
2006-10-21 19:40:29 +00:00
|
|
|
|
odocstringstream entities;
|
2001-10-23 09:42:14 +00:00
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
if (mustProvide("lyxarrow")) {
|
2001-11-29 17:12:21 +00:00
|
|
|
|
entities << "<!ENTITY lyxarrow \"->\">" << '\n';
|
2001-10-23 09:42:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return entities.str();
|
2001-10-23 09:42:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 19:40:29 +00:00
|
|
|
|
docstring const LaTeXFeatures::getIncludedFiles(string const & fname) const
|
2000-07-01 12:54:45 +00:00
|
|
|
|
{
|
2006-10-21 19:40:29 +00:00
|
|
|
|
odocstringstream sgmlpreamble;
|
2007-03-27 07:24:16 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
docstring const basename(from_utf8(onlyPath(fname)));
|
2000-11-13 15:43:36 +00:00
|
|
|
|
|
2003-09-18 14:01:02 +00:00
|
|
|
|
FileMap::const_iterator end = IncludedFiles_.end();
|
|
|
|
|
for (FileMap::const_iterator fi = IncludedFiles_.begin();
|
2000-10-11 21:06:43 +00:00
|
|
|
|
fi != end; ++fi)
|
2007-03-27 07:24:16 +00:00
|
|
|
|
// FIXME UNICODE
|
2001-05-08 17:08:44 +00:00
|
|
|
|
sgmlpreamble << "\n<!ENTITY " << fi->first
|
2006-04-08 09:09:57 +00:00
|
|
|
|
<< (isSGMLFilename(fi->second) ? " SYSTEM \"" : " \"")
|
2007-03-27 07:24:16 +00:00
|
|
|
|
<< makeRelPath(from_utf8(fi->second), basename) << "\">";
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return sgmlpreamble.str();
|
2000-07-01 12:54:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-20 15:00:11 +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()
|
2006-11-08 17:22:44 +00:00
|
|
|
|
<< "\n***** Textclass stuff:" << to_utf8(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
|
|
|
|
|
|
|
|
|
|
2003-09-18 14:13:23 +00:00
|
|
|
|
Buffer const & LaTeXFeatures::buffer() const
|
|
|
|
|
{
|
2004-04-08 10:09:09 +00:00
|
|
|
|
return *buffer_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LaTeXFeatures::setBuffer(Buffer const & buffer)
|
|
|
|
|
{
|
|
|
|
|
buffer_ = &buffer;
|
2003-09-18 14:13:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
|
BufferParams const & LaTeXFeatures::bufferParams() const
|
|
|
|
|
{
|
2003-09-18 14:01:02 +00:00
|
|
|
|
return params_;
|
2000-04-10 21:40:13 +00:00
|
|
|
|
}
|
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
|
|
|
|
{
|
2008-02-28 01:42:02 +00:00
|
|
|
|
FloatList const & floats = params_.documentClass().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}
|
2003-09-18 14:01:02 +00:00
|
|
|
|
UsedFloats::const_iterator cit = usedFloats_.begin();
|
|
|
|
|
UsedFloats::const_iterator end = usedFloats_.end();
|
2001-05-08 17:08:44 +00:00
|
|
|
|
// ostringstream floats;
|
|
|
|
|
for (; cit != end; ++cit) {
|
2008-03-02 11:30:50 +00:00
|
|
|
|
Floating const & fl = floats.getType((cit->first));
|
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)
|
|
|
|
|
}
|
2008-03-02 11:30:50 +00:00
|
|
|
|
if (cit->second)
|
|
|
|
|
os << "\n\\newsubfloat{" << fl.type() << "}\n";
|
2001-05-08 17:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|