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
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author José Matos
|
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
|
|
|
* \author André Pö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
|
|
|
|
2009-02-04 20:06:50 +00:00
|
|
|
#include "Buffer.h"
|
2007-10-25 12:41:02 +00:00
|
|
|
#include "BufferParams.h"
|
2009-02-09 23:30:24 +00:00
|
|
|
#include "ColorSet.h"
|
2009-05-28 08:59:25 +00:00
|
|
|
#include "Converter.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"
|
2012-09-19 13:46:19 +00:00
|
|
|
#include "LaTeXFonts.h"
|
2011-11-06 17:03:59 +00:00
|
|
|
#include "LaTeXPackages.h"
|
2007-09-29 20:02:32 +00:00
|
|
|
#include "Layout.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyXRC.h"
|
2020-11-22 22:23:39 +00:00
|
|
|
#include "OutputParams.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
#include "TextClass.h"
|
2016-09-25 10:38:53 +00:00
|
|
|
#include "TexRow.h"
|
|
|
|
#include "texstream.h"
|
2000-12-29 12:48:02 +00:00
|
|
|
|
2009-06-03 23:44:31 +00:00
|
|
|
#include "insets/InsetLayout.h"
|
|
|
|
|
2008-02-01 15:54:40 +00:00
|
|
|
#include "support/debug.h"
|
2006-10-21 19:40:29 +00:00
|
|
|
#include "support/docstream.h"
|
2020-10-20 08:36:59 +00:00
|
|
|
#include "support/docstring.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
|
|
|
|
2010-06-06 10:07:49 +00:00
|
|
|
#include <algorithm>
|
2020-11-28 23:05:24 +00:00
|
|
|
#include <regex>
|
2010-06-06 10:07:49 +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.}
|
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const lyx_def = from_ascii(
|
2019-03-07 16:01:05 +00:00
|
|
|
"{%\n L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}");
|
2011-01-10 17:27:56 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const noun_def = from_ascii(
|
|
|
|
"\\newcommand{\\noun}[1]{\\textsc{#1}}");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const lyxarrow_def = from_ascii(
|
2009-01-18 14:00:43 +00:00
|
|
|
"\\DeclareRobustCommand*{\\lyxarrow}{%\n"
|
2009-01-11 08:31:52 +00:00
|
|
|
"\\@ifstar\n"
|
|
|
|
"{\\leavevmode\\,$\\triangleleft$\\,\\allowbreak}\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"{\\leavevmode\\,$\\triangleright$\\,\\allowbreak}}");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2021-01-04 21:36:01 +00:00
|
|
|
static docstring const aastex_case_def = from_ascii(
|
|
|
|
"\\providecommand\\case[2]{\\mbox{$\\frac{#1}{#2}$}}%");
|
|
|
|
// Copied from https://github.com/AASJournals/AASTeX60/blob/master/cls/aastex63.cls#L1645
|
|
|
|
// Adapted to providecommand for compatibility reasons.
|
|
|
|
|
2017-03-06 13:49:30 +00:00
|
|
|
// ZERO WIDTH SPACE (ZWSP) is actually not a space character
|
|
|
|
// but marks a line break opportunity. Several commands provide a
|
|
|
|
// line break opportunity. They differ in side-effects:
|
|
|
|
// \allowbreak prevents hyphenation after hyphen or dash + ZWSP
|
|
|
|
// \linebreak[<n>] takes an optional argument denoting "urgency".
|
|
|
|
// The \LyXZeroWidthSpace wrapper allows customization in the preamble.
|
|
|
|
static docstring const lyxZWSP_def = from_ascii(
|
|
|
|
"\\newcommand*\\LyXZeroWidthSpace{\\hspace{0pt}}");
|
|
|
|
|
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).
|
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const quotedblbase_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\quotedblbase}{%\n"
|
|
|
|
" \\raisebox{-1.4ex}[1ex][.5ex]{\\textquotedblright}%\n"
|
|
|
|
" \\penalty10000\\hskip0em\\relax%\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"}");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const quotesinglbase_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\quotesinglbase}{%\n"
|
|
|
|
" \\raisebox{-1.4ex}[1ex][.5ex]{\\textquoteright}%\n"
|
|
|
|
" \\penalty10000\\hskip0em\\relax%\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"}");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const guillemotleft_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\guillemotleft}{%\n"
|
|
|
|
" {\\usefont{U}{lasy}{m}{n}\\char'50\\kern-.15em\\char'50}%\n"
|
|
|
|
"\\penalty10000\\hskip0pt\\relax%\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"}");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const guillemotright_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\guillemotright}{%\n"
|
|
|
|
" \\penalty10000\\hskip0pt%\n"
|
|
|
|
" {\\usefont{U}{lasy}{m}{n}\\char'51\\kern-.15em\\char'51}%\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"}");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const guilsinglleft_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\guilsinglleft}{%\n"
|
|
|
|
" {\\usefont{U}{lasy}{m}{n}\\char'50}%\n"
|
|
|
|
" \\penalty10000\\hskip0pt\\relax%\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"}");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const guilsinglright_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\guilsinglright}{%\n"
|
|
|
|
" \\penalty10000\\hskip0pt%\n"
|
|
|
|
" {\\usefont{U}{lasy}{m}{n}\\char'51}%\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"}");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2016-12-21 14:17:30 +00:00
|
|
|
static docstring const textquotedbl_def = from_ascii(
|
|
|
|
"\\DeclareTextSymbolDefault{\\textquotedbl}{T1}");
|
|
|
|
|
|
|
|
static docstring const textquotedblp_xetex_def = from_ascii(
|
|
|
|
"\\providecommand\\textquotedblplain{%\n"
|
2017-02-18 09:18:36 +00:00
|
|
|
" \\bgroup\\addfontfeatures{Mapping=}\\char34\\egroup}");
|
2016-12-21 14:17:30 +00:00
|
|
|
|
|
|
|
static docstring const textquotedblp_luatex_def = from_ascii(
|
|
|
|
"\\providecommand\\textquotedblplain{%\n"
|
2017-02-18 09:18:36 +00:00
|
|
|
" \\bgroup\\addfontfeatures{RawFeature=-tlig}\\char34\\egroup}");
|
2016-12-21 14:17:30 +00:00
|
|
|
|
|
|
|
static docstring const textquotesinglep_xetex_def = from_ascii(
|
|
|
|
"\\providecommand\\textquotesingleplain{%\n"
|
2017-02-18 09:18:36 +00:00
|
|
|
" \\bgroup\\addfontfeatures{Mapping=}\\char39\\egroup}");
|
2016-12-21 14:17:30 +00:00
|
|
|
|
|
|
|
static docstring const textquotesinglep_luatex_def = from_ascii(
|
|
|
|
"\\providecommand\\textquotesingleplain{%\n"
|
2017-02-18 09:18:36 +00:00
|
|
|
" \\bgroup\\addfontfeatures{RawFeature=-tlig}\\char39\\egroup}");
|
2016-12-21 14:17:30 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const paragraphleftindent_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"\\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"
|
2009-06-09 18:16:43 +00:00
|
|
|
"{\\end{list}}\n");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2016-01-26 20:33:46 +00:00
|
|
|
static docstring const floatingfootnote_def = from_ascii(
|
|
|
|
"%% 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");
|
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const binom_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"%% Binom macro for standard LaTeX users\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const mathcircumflex_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"%% For printing a cirumflex inside a formula\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\mathcircumflex}[0]{\\mbox{\\^{}}}\n");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const tabularnewline_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"%% Because html converters don't know tabularnewline\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\providecommand{\\tabularnewline}{\\\\}\n");
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2021-01-22 18:16:43 +00:00
|
|
|
static docstring const cellvarwidth_def = from_ascii(
|
|
|
|
"%% Variable width box for table cells\n"
|
|
|
|
"\\newenvironment{cellvarwidth}[1][t]\n"
|
|
|
|
" {\\begin{varwidth}[#1]{\\linewidth}}\n"
|
|
|
|
" {\\@finalstrut\\@arstrutbox\\end{varwidth}}\n");
|
|
|
|
|
2007-04-30 20:20:05 +00:00
|
|
|
// 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
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const lyxdot_def = from_ascii(
|
2007-04-30 20:20:05 +00:00
|
|
|
"%% A simple dot to overcome graphicx limitations\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\lyxdot}{.}\n");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2019-12-28 12:41:19 +00:00
|
|
|
static docstring const changetracking_xcolor_ulem_base_def = from_ascii(
|
|
|
|
"%% Change tracking with ulem and xcolor: base macros\n"
|
|
|
|
"\\DeclareRobustCommand{\\mklyxadded}[1]{\\bgroup\\color{lyxadded}{}#1\\egroup}\n"
|
|
|
|
"\\DeclareRobustCommand{\\mklyxdeleted}[1]{\\bgroup\\color{lyxdeleted}\\mklyxsout{#1}\\egroup}\n"
|
|
|
|
"\\DeclareRobustCommand{\\mklyxsout}[1]{\\ifx\\\\#1\\else\\sout{#1}\\fi}\n");
|
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const changetracking_xcolor_ulem_def = from_ascii(
|
2019-12-28 12:41:19 +00:00
|
|
|
"%% Change tracking with ulem and xcolor: ct markup\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxadded}[4][]{\\mklyxadded{#4}}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxdeleted}[4][]{\\mklyxdeleted{#4}}\n");
|
2008-01-19 11:17:12 +00:00
|
|
|
|
2019-12-24 17:12:22 +00:00
|
|
|
static docstring const changetracking_xcolor_ulem_cb_def = from_ascii(
|
2019-12-28 12:41:19 +00:00
|
|
|
"%% Change tracking with ulem, xcolor and changebars: ct markup\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxadded}[4][]{%\n"
|
|
|
|
" \\protect\\cbstart\\mklyxadded{#4}%\n"
|
2019-12-24 17:12:22 +00:00
|
|
|
" \\protect\\cbend%\n"
|
2019-12-28 12:41:19 +00:00
|
|
|
"}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxdeleted}[4][]{%\n"
|
|
|
|
" \\protect\\cbstart\\mklyxdeleted{#4}%\n"
|
2019-12-24 17:12:22 +00:00
|
|
|
" \\protect\\cbend%\n"
|
2019-12-28 12:41:19 +00:00
|
|
|
"}\n");
|
2019-12-24 17:12:22 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const changetracking_xcolor_ulem_hyperref_def = from_ascii(
|
2019-12-28 12:41:19 +00:00
|
|
|
"%% Change tracking with ulem, xcolor, and hyperref: ct markup\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxadded}[4][]{\\texorpdfstring{\\mklyxadded{#4}}{#4}}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxdeleted}[4][]{\\texorpdfstring{\\mklyxdeleted{#4}}{}}\n");
|
2016-10-17 01:25:35 +00:00
|
|
|
|
2019-12-24 17:12:22 +00:00
|
|
|
static docstring const changetracking_xcolor_ulem_hyperref_cb_def = from_ascii(
|
2019-12-28 12:41:19 +00:00
|
|
|
"%% Change tracking with ulem, xcolor, hyperref and changebars: ct markup\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxadded}[4][]{%\n"
|
|
|
|
" \\texorpdfstring{\\protect\\cbstart\\mklyxadded{#4}%\n"
|
|
|
|
" \\protect\\cbend}{#4}%\n"
|
|
|
|
"}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxdeleted}[4][]{%\n"
|
|
|
|
" \\texorpdfstring{\\protect\\cbstart\\mklyxdeleted{#4}%\n"
|
2019-12-24 17:12:22 +00:00
|
|
|
" \\protect\\cbend}{}%\n"
|
2019-12-28 12:41:19 +00:00
|
|
|
"}\n");
|
2019-12-24 17:12:22 +00:00
|
|
|
|
2019-12-26 06:15:37 +00:00
|
|
|
static docstring const changetracking_tikz_object_sout_def = from_ascii(
|
|
|
|
"%% Strike out display math and text objects with tikz\n"
|
2016-10-17 01:25:35 +00:00
|
|
|
"\\usetikzlibrary{calc}\n"
|
2019-12-26 06:15:37 +00:00
|
|
|
"\\newcommand{\\lyxobjectsout}[1]{%\n"
|
2019-12-27 08:50:11 +00:00
|
|
|
" \\bgroup%\n"
|
|
|
|
" \\color{lyxdeleted}%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
" \\tikz{\n"
|
|
|
|
" \\node[inner sep=0pt,outer sep=0pt](lyxdelobj){#1};\n"
|
|
|
|
" \\draw($(lyxdelobj.south west)+(2em,.5em)$)--($(lyxdelobj.north east)-(2em,.5em)$);\n"
|
2016-10-17 01:25:35 +00:00
|
|
|
" }\n"
|
2019-12-27 08:50:11 +00:00
|
|
|
" \\egroup%\n"
|
2016-10-17 01:25:35 +00:00
|
|
|
"}\n");
|
2008-01-19 11:17:12 +00:00
|
|
|
|
2019-12-28 12:43:17 +00:00
|
|
|
static docstring const changetracking_xcolor_ulem_object_def = from_ascii(
|
|
|
|
"%% Change tracking with ulem and xcolor: ct markup for complex objects\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxobjdeleted}[4][]{\\lyxobjectsout{#4}}\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
"\\DeclareRobustCommand{\\lyxdisplayobjdeleted}[4][]{%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\ifx#4\\empty\\else%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
" \\leavevmode\\\\%\n"
|
|
|
|
" \\lyxobjectsout{\\parbox{\\linewidth}{#4}}%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\fi%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
"}\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"\\DeclareRobustCommand{\\lyxudisplayobjdeleted}[4][]{%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\ifx#4\\empty\\else%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
" \\leavevmode\\\\%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
" \\raisebox{-\\belowdisplayshortskip}{%\n"
|
|
|
|
" \\lyxobjectsout{\\parbox[b]{\\linewidth}{#4}}}%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\leavevmode\\\\%\n"
|
|
|
|
" \\fi%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"}\n");
|
|
|
|
|
|
|
|
static docstring const changetracking_xcolor_ulem_cb_object_def = from_ascii(
|
|
|
|
"%% Change tracking with ulem, xcolor and changebars:ct markup for complex objects\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxobjdeleted}[4][]{%\n"
|
|
|
|
" \\protect\\cbstart\\lyxobjectsout{#4}%\n"
|
|
|
|
" \\protect\\cbend%\n"
|
|
|
|
"}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxdisplayobjdeleted}[4][]{%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\ifx#4\\empty\\else%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
" \\leavevmode\\\\%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
" \\protect\\cbstart%\n"
|
|
|
|
" \\lyxobjectsout{\\parbox{\\linewidth}{#4}}%\n"
|
|
|
|
" \\protect\\cbend%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\fi%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxudisplayobjdeleted}[4][]{%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\ifx#4\\empty\\else%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
" \\leavevmode\\\\%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
" \\raisebox{-\\belowdisplayshortskip}{%\n"
|
|
|
|
" \\protect\\cbstart%\n"
|
|
|
|
" \\lyxobjectsout{\\parbox[b]{\\linewidth}{#4}}}%\n"
|
|
|
|
" \\protect\\cbend%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\leavevmode\\\\%\n"
|
|
|
|
" \\fi%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"}\n");
|
|
|
|
|
|
|
|
static docstring const changetracking_xcolor_ulem_hyperref_object_def = from_ascii(
|
|
|
|
"%% Change tracking with ulem, xcolor, and hyperref: ct markup for complex objects\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxobjdeleted}[4][]{\\texorpdfstring{\\lyxobjectsout{#4}}{}}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxdisplayobjdeleted}[4][]{%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\ifx#4\\empty\\else%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
" \\texorpdfstring{\\leavevmode\\\\\\lyxobjectsout{\\parbox{\\linewidth}{#4}}}{}%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\fi%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxudisplayobjdeleted}[4][]{%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\ifx#4\\empty\\else%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
" \\texorpdfstring{\\leavevmode\\\\\\raisebox{-\\belowdisplayshortskip}{%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
" \\lyxobjectsout{\\parbox[b]{\\linewidth}{#4}}}}{}%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\leavevmode\\\\%\n"
|
|
|
|
" \\fi%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"}\n");
|
|
|
|
|
|
|
|
static docstring const changetracking_xcolor_ulem_hyperref_cb_object_def = from_ascii(
|
|
|
|
"%% Change tracking with ulem, xcolor, hyperref and changebars:\n"
|
|
|
|
"%% ct markup for complex objects\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxobjdeleted}[4][]{%\n"
|
|
|
|
" \\texorpdfstring{\\protect\\cbstart\\lyxobjectsout{#4}%\n"
|
|
|
|
" \\protect\\cbend}{}%\n"
|
|
|
|
"}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxdisplayobjdeleted}[4][]{%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\ifx#4\\empty\\else%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
" \\texorpdfstring{\\leavevmode\\\\\\protect\\cbstart%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
" \\lyxobjectsout{\\parbox{\\linewidth}{#4}}%\n"
|
|
|
|
" \\protect\\cbend%\n"
|
|
|
|
" }{}%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\fi%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"}\n"
|
|
|
|
"\\DeclareRobustCommand{\\lyxudisplayobjdeleted}[4][]{%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\ifx#4\\empty\\else%\n"
|
2019-12-29 09:10:14 +00:00
|
|
|
" \\texorpdfstring{\\leavevmode\\\\\\protect\\cbstart%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
" \\raisebox{-\\belowdisplayshortskip}{%\n"
|
|
|
|
" \\lyxobjectsout{\\parbox[b]{\\linewidth}{#4}}%\n"
|
|
|
|
" }%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\leavevmode\\\\%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
" }{}%\n"
|
2019-12-30 12:00:03 +00:00
|
|
|
" \\fi%\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"}\n");
|
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const changetracking_none_def = from_ascii(
|
2019-12-28 12:43:17 +00:00
|
|
|
"%% Change tracking: Disable markup in output\n"
|
2007-05-13 15:17:57 +00:00
|
|
|
"\\newcommand{\\lyxadded}[3]{#3}\n"
|
2019-12-28 12:43:17 +00:00
|
|
|
"\\newcommand{\\lyxdeleted}[3]{}\n"
|
|
|
|
"\\newcommand{\\lyxobjdeleted}[3]{}\n"
|
|
|
|
"\\newcommand{\\lyxdisplayobjdeleted}[3]{}\n"
|
|
|
|
"\\newcommand{\\lyxudisplayobjdeleted}[3]{}\n");
|
2007-04-30 20:20:05 +00:00
|
|
|
|
2015-07-11 13:39:02 +00:00
|
|
|
static docstring const textgreek_LGR_def = from_ascii(
|
|
|
|
"\\DeclareFontEncoding{LGR}{}{}\n");
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const textgreek_def = from_ascii(
|
2010-04-09 09:27:54 +00:00
|
|
|
"\\DeclareRobustCommand{\\greektext}{%\n"
|
|
|
|
" \\fontencoding{LGR}\\selectfont\\def\\encodingdefault{LGR}}\n"
|
2018-01-30 20:58:12 +00:00
|
|
|
"\\DeclareRobustCommand{\\textgreek}[1]{\\leavevmode{\\greektext #1}}\n");
|
2015-07-14 12:47:44 +00:00
|
|
|
|
|
|
|
static docstring const textcyr_T2A_def = from_ascii(
|
|
|
|
"\\InputIfFileExists{t2aenc.def}{}{%\n"
|
|
|
|
" \\errmessage{File `t2aenc.def' not found: Cyrillic script not supported}}\n");
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const textcyr_def = from_ascii(
|
2007-10-12 18:21:51 +00:00
|
|
|
"\\DeclareRobustCommand{\\cyrtext}{%\n"
|
2008-09-26 15:53:15 +00:00
|
|
|
" \\fontencoding{T2A}\\selectfont\\def\\encodingdefault{T2A}}\n"
|
2018-04-21 14:28:15 +00:00
|
|
|
"\\DeclareRobustCommand{\\textcyrillic}[1]{\\leavevmode{\\cyrtext #1}}\n");
|
2008-05-31 20:54:50 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const lyxmathsym_def = from_ascii(
|
2009-03-30 22:40:27 +00:00
|
|
|
"\\newcommand{\\lyxmathsym}[1]{\\ifmmode\\begingroup\\def\\b@ld{bold}\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
" \\text{\\ifx\\math@version\\b@ld\\bfseries\\fi#1}\\endgroup\\else#1\\fi}\n");
|
2008-05-31 20:54:50 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const papersizedvi_def = from_ascii(
|
|
|
|
"\\special{papersize=\\the\\paperwidth,\\the\\paperheight}\n");
|
2008-07-01 12:46:46 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const papersizepdf_def = from_ascii(
|
2008-07-01 12:46:46 +00:00
|
|
|
"\\pdfpageheight\\paperheight\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\pdfpagewidth\\paperwidth\n");
|
2008-07-01 12:46:46 +00:00
|
|
|
|
2016-07-09 14:45:27 +00:00
|
|
|
static docstring const papersizepdflua_def = from_ascii(
|
|
|
|
"% Backwards compatibility for LuaTeX < 0.90\n"
|
2016-09-04 15:44:47 +00:00
|
|
|
"\\@ifundefined{pageheight}{\\let\\pageheight\\pdfpageheight}{}\n"
|
|
|
|
"\\@ifundefined{pagewidth}{\\let\\pagewidth\\pdfpagewidth}{}\n"
|
2016-07-09 14:45:27 +00:00
|
|
|
"\\pageheight\\paperheight\n"
|
|
|
|
"\\pagewidth\\paperwidth\n");
|
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const cedilla_def = from_ascii(
|
2008-09-26 15:53:15 +00:00
|
|
|
"\\newcommand{\\docedilla}[2]{\\underaccent{#1\\mathchar'30}{#2}}\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\cedilla}[1]{\\mathpalette\\docedilla{#1}}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const subring_def = from_ascii(
|
2008-09-26 15:53:15 +00:00
|
|
|
"\\newcommand{\\dosubring}[2]{\\underaccent{#1\\mathchar'27}{#2}}\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\subring}[1]{\\mathpalette\\dosubring{#1}}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const subdot_def = from_ascii(
|
2008-09-26 15:53:15 +00:00
|
|
|
"\\newcommand{\\dosubdot}[2]{\\underaccent{#1.}{#2}}\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\subdot}[1]{\\mathpalette\\dosubdot{#1}}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const subhat_def = from_ascii(
|
2008-09-26 15:53:15 +00:00
|
|
|
"\\newcommand{\\dosubhat}[2]{\\underaccent{#1\\mathchar'136}{#2}}\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\subhat}[1]{\\mathpalette\\dosubhat{#1}}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const subtilde_def = from_ascii(
|
2008-09-26 15:53:15 +00:00
|
|
|
"\\newcommand{\\dosubtilde}[2]{\\underaccent{#1\\mathchar'176}{#2}}\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\subtilde}[1]{\\mathpalette\\dosubtilde{#1}}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const dacute_def = from_ascii(
|
|
|
|
"\\DeclareMathAccent{\\dacute}{\\mathalpha}{operators}{'175}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const tipasymb_def = from_ascii(
|
2008-09-26 15:53:15 +00:00
|
|
|
"\\DeclareFontEncoding{T3}{}{}\n"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\DeclareSymbolFont{tipasymb}{T3}{cmr}{m}{n}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const dgrave_def = from_ascii(
|
|
|
|
"\\DeclareMathAccent{\\dgrave}{\\mathord}{tipasymb}{'15}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const rcap_def = from_ascii(
|
|
|
|
"\\DeclareMathAccent{\\rcap}{\\mathord}{tipasymb}{'20}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
static docstring const ogonek_def = from_ascii(
|
2008-09-26 15:53:15 +00:00
|
|
|
"\\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"
|
2009-06-09 18:16:43 +00:00
|
|
|
"\\newcommand{\\ogonek}[1]{\\mathpalette\\doogonek{#1}}\n");
|
2008-09-26 15:53:15 +00:00
|
|
|
|
2015-07-12 14:21:25 +00:00
|
|
|
static docstring const lyxaccent_def = from_ascii(
|
|
|
|
"%% custom text accent \\LyxTextAccent[<rise value (length)>]{<accent>}{<base>}\n"
|
2019-03-16 11:59:34 +00:00
|
|
|
"\\newcommand*{\\LyxTextAccent}[3][0ex]{%\n"
|
|
|
|
" \\hmode@bgroup\\ooalign{\\null#3\\crcr\\hidewidth\n"
|
|
|
|
" \\raise#1\\hbox{#2}\\hidewidth}\\egroup}\n"
|
|
|
|
"%% select a font size smaller than the current font size:\n"
|
|
|
|
"\\newcommand{\\LyxAccentSize}[1][\\sf@size]{%\n"
|
|
|
|
" \\check@mathfonts\\fontsize#1\\z@\\math@fontsfalse\\selectfont\n"
|
|
|
|
"}\n");
|
2015-07-12 14:21:25 +00:00
|
|
|
|
|
|
|
static docstring const textcommabelow_def = from_ascii(
|
2019-03-16 11:59:34 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\textcommabelow}[1]{%%\n"
|
|
|
|
" \\LyxTextAccent[-.31ex]{\\LyxAccentSize,}{#1}}\n");
|
2015-07-12 14:21:25 +00:00
|
|
|
|
|
|
|
static docstring const textcommaabove_def = from_ascii(
|
2019-03-16 11:59:34 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\textcommaabove}[1]{%%\n"
|
|
|
|
" \\LyxTextAccent[.5ex]{\\LyxAccentSize`}{#1}}\n");
|
2015-07-12 14:21:25 +00:00
|
|
|
|
|
|
|
static docstring const textcommaaboveright_def = from_ascii(
|
2019-03-16 11:59:34 +00:00
|
|
|
"\\ProvideTextCommandDefault{\\textcommaaboveright}[1]{%%\n"
|
|
|
|
" \\LyxTextAccent[.5ex]{\\LyxAccentSize\\ '}{#1}}\n");
|
2015-07-12 14:21:25 +00:00
|
|
|
|
|
|
|
// Baltic languages use a comma-accent instead of a cedilla
|
|
|
|
static docstring const textbaltic_def = from_ascii(
|
2019-03-16 11:59:34 +00:00
|
|
|
"%% use comma accent instead of cedilla for these characters:\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{g}{\\textcommaabove{g}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{G}{\\textcommabelow{G}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{k}{\\textcommabelow{k}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{K}{\\textcommabelow{K}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{l}{\\textcommabelow{l}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{L}{\\textcommabelow{L}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{n}{\\textcommabelow{n}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{N}{\\textcommabelow{N}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{r}{\\textcommabelow{r}}\n"
|
|
|
|
"\\DeclareTextCompositeCommand{\\c}{T1}{R}{\\textcommabelow{R}}\n");
|
2015-07-12 14:21:25 +00:00
|
|
|
|
2019-05-14 15:12:46 +00:00
|
|
|
// Use cyrillic fonts to provide letter schwa in text (see #11062)
|
|
|
|
static docstring const textschwa_def = from_ascii(
|
|
|
|
"%% letter schwa missing in Latin fonts, use Cyrillic schwa\n"
|
|
|
|
"\\DeclareTextSymbolDefault{\\CYRSCHWA}{T2A}\n"
|
|
|
|
"\\DeclareTextSymbolDefault{\\cyrschwa}{T2A}\n"
|
|
|
|
"\\ProvideTextCommandDefault{\\textSchwa}{\\CYRSCHWA}\n"
|
|
|
|
"\\ProvideTextCommandDefault{\\textschwa}{\\cyrschwa}\n");
|
|
|
|
|
2016-12-18 22:41:43 +00:00
|
|
|
// split-level fractions
|
|
|
|
static docstring const xfrac_def = from_ascii(
|
|
|
|
"\\usepackage{xfrac}\n");
|
2021-01-20 07:59:52 +00:00
|
|
|
|
2016-12-18 22:41:43 +00:00
|
|
|
static docstring const smallLetterFrac_def = from_ascii(
|
2019-03-16 11:59:34 +00:00
|
|
|
"\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{default}{text}\n"
|
|
|
|
" {phantom=c, scale-factor=1.0, slash-left-kern=-.05em}\n"
|
|
|
|
"\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{lmr}{text}\n"
|
|
|
|
" {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
|
|
|
|
"\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{lmss}{text}\n"
|
|
|
|
" {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
|
|
|
|
"\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{cmr}{text}\n"
|
|
|
|
" {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
|
|
|
|
"\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{cmss}{text}\n"
|
|
|
|
" {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
|
|
|
|
"\\newcommand{\\smallLetterFrac}[2]{%\n"
|
|
|
|
" {\\UseCollection{xfrac}{smallLetterFrac}\\sfrac{#1}{#2}}}\n");
|
2016-12-18 22:41:43 +00:00
|
|
|
|
2010-10-28 16:04:46 +00:00
|
|
|
static docstring const lyxref_def = from_ascii(
|
2019-03-16 11:59:34 +00:00
|
|
|
"\\RS@ifundefined{subsecref}\n"
|
|
|
|
" {\\newref{subsec}{name = \\RSsectxt}}\n"
|
|
|
|
" {}\n"
|
|
|
|
"\\RS@ifundefined{thmref}\n"
|
|
|
|
" {\\def\\RSthmtxt{theorem~}\\newref{thm}{name = \\RSthmtxt}}\n"
|
|
|
|
" {}\n"
|
|
|
|
"\\RS@ifundefined{lemref}\n"
|
|
|
|
" {\\def\\RSlemtxt{lemma~}\\newref{lem}{name = \\RSlemtxt}}\n"
|
|
|
|
" {}\n");
|
2010-10-28 16:04:46 +00:00
|
|
|
|
2012-09-22 21:14:34 +00:00
|
|
|
// Make sure the columns are also outputed as rtl
|
|
|
|
static docstring const rtloutputdblcol_def = from_ascii(
|
|
|
|
"\\def\\@outputdblcol{%\n"
|
|
|
|
" \\if@firstcolumn\n"
|
|
|
|
" \\global \\@firstcolumnfalse\n"
|
|
|
|
" \\global \\setbox\\@leftcolumn \\box\\@outputbox\n"
|
|
|
|
" \\else\n"
|
|
|
|
" \\global \\@firstcolumntrue\n"
|
|
|
|
" \\setbox\\@outputbox \\vbox {%\n"
|
|
|
|
" \\hb@xt@\\textwidth {%\n"
|
|
|
|
" \\kern\\textwidth \\kern-\\columnwidth %**\n"
|
|
|
|
" \\hb@xt@\\columnwidth {%\n"
|
|
|
|
" \\box\\@leftcolumn \\hss}%\n"
|
|
|
|
" \\kern-\\textwidth %**\n"
|
|
|
|
" \\hfil\n"
|
|
|
|
" {\\normalcolor\\vrule \\@width\\columnseprule}%\n"
|
|
|
|
" \\hfil\n"
|
|
|
|
" \\kern-\\textwidth %**\n"
|
|
|
|
" \\hb@xt@\\columnwidth {%\n"
|
|
|
|
" \\box\\@outputbox \\hss}%\n"
|
|
|
|
" \\kern-\\columnwidth \\kern\\textwidth %**\n"
|
|
|
|
" }%\n"
|
|
|
|
" }%\n"
|
|
|
|
" \\@combinedblfloats\n"
|
|
|
|
" \\@outputpage\n"
|
|
|
|
" \\begingroup\n"
|
|
|
|
" \\@dblfloatplacement\n"
|
|
|
|
" \\@startdblcolumn\n"
|
|
|
|
" \\@whilesw\\if@fcolmade \\fi\n"
|
|
|
|
" {\\@outputpage\n"
|
|
|
|
" \\@startdblcolumn}%\n"
|
|
|
|
" \\endgroup\n"
|
|
|
|
" \\fi\n"
|
|
|
|
"}\n"
|
|
|
|
"\\@mparswitchtrue\n");
|
|
|
|
|
2017-06-10 16:43:23 +00:00
|
|
|
static docstring const lyxmintcaption_def = from_ascii(
|
|
|
|
"\\long\\def\\lyxmintcaption[#1]#2{%\n"
|
|
|
|
" \\ifx#1t\\vskip\\baselineskip\\fi%\n"
|
|
|
|
" \\refstepcounter{listing}\\noindent%\n"
|
2017-06-10 19:00:43 +00:00
|
|
|
" \\addcontentsline{lol}{listing}%\n"
|
|
|
|
" {\\protect\\numberline{\\thelisting}{\\ignorespaces #2}}%\n"
|
2017-06-10 16:43:23 +00:00
|
|
|
" \\setbox\\@tempboxa\\hbox{\\listingscaption~\\thelisting: #2}%\n"
|
|
|
|
" \\ifdim \\wd\\@tempboxa >\\linewidth%\n"
|
|
|
|
" \\parbox[t]{\\linewidth}{\\unhbox\\@tempboxa}\\else%\n"
|
|
|
|
" \\hbox to\\linewidth{\\hfil\\box\\@tempboxa\\hfil}\\fi%\n"
|
|
|
|
" \\ifx#1b\\vskip\\baselineskip\\fi\n"
|
|
|
|
"}\n");
|
|
|
|
|
2021-01-20 07:59:52 +00:00
|
|
|
|
2021-01-20 10:04:16 +00:00
|
|
|
docstring const lyxgreyedoutDef(bool const rtl, bool const ct, bool const lua, bool const babel)
|
2021-01-20 07:59:52 +00:00
|
|
|
{
|
|
|
|
odocstringstream ods;
|
|
|
|
|
2021-01-20 10:04:16 +00:00
|
|
|
if (rtl) {
|
|
|
|
ods << "%% The greyedout annotation environment (with RTL support)\n"
|
|
|
|
<< "\\NewEnviron{lyxgreyedout}{%\n";
|
|
|
|
if (lua && !babel)
|
|
|
|
// luabidi uses this switch
|
|
|
|
ods << " \\if@RTL%\n";
|
|
|
|
else
|
|
|
|
ods << " \\if@rl%\n";
|
|
|
|
ods << " \\everypar{%\n";
|
|
|
|
if (lua)
|
2021-01-20 10:14:24 +00:00
|
|
|
ods << " \\pardir TRT \\textdir TRT\\textcolor{note_fontcolor}\\ignorespaces%\n";
|
2021-01-20 10:04:16 +00:00
|
|
|
else
|
2021-01-20 10:14:24 +00:00
|
|
|
ods << " \\textcolor{note_fontcolor}\\beginL\\ignorespaces%\n";
|
|
|
|
ods << " }%\n";
|
2021-01-20 10:04:16 +00:00
|
|
|
if (ct)
|
|
|
|
ods << " \\colorlet{lyxadded}{lyxadded!30}\\colorlet{lyxdeleted}{lyxdeleted!30}%\n";
|
|
|
|
if (lua)
|
|
|
|
ods << " \\BODY\\everypar{\\ignorespacesafterend}%\n";
|
|
|
|
else
|
|
|
|
ods << " \\BODY\\everypar{\\ignorespacesafterend\\endL}%\n";
|
|
|
|
ods << " \\else%\n";
|
|
|
|
if (ct)
|
|
|
|
ods << " \\colorlet{lyxadded}{lyxadded!30}\\colorlet{lyxdeleted}{lyxdeleted!30}%\n";
|
|
|
|
ods << " \\textcolor{note_fontcolor}\\bgroup\\ignorespaces%\n"
|
|
|
|
<< " \\BODY\\ignorespacesafterend\\egroup%\n"
|
|
|
|
<< " \\fi%\n"
|
|
|
|
<< "}\n";
|
|
|
|
} else {
|
|
|
|
ods << "%% The greyedout annotation environment\n"
|
|
|
|
<< "\\newenvironment{lyxgreyedout}\n"
|
|
|
|
<< "{";
|
|
|
|
if (ct)
|
|
|
|
ods << "\\colorlet{lyxadded}{lyxadded!30}\\colorlet{lyxdeleted}{lyxdeleted!30}%\n ";
|
|
|
|
ods << "\\textcolor{note_fontcolor}\\bgroup\\ignorespaces}\n"
|
|
|
|
<< "{\\ignorespacesafterend\\egroup}\n";
|
|
|
|
}
|
2021-01-20 07:59:52 +00:00
|
|
|
|
|
|
|
return ods.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-28 16:04:46 +00:00
|
|
|
|
2013-03-27 16:49:03 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// LyXHTML strings
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static docstring const lyxnoun_style = from_ascii(
|
|
|
|
"dfn.lyxnoun {\n"
|
2015-05-17 15:27:12 +00:00
|
|
|
" font-variant: small-caps;\n"
|
|
|
|
"}\n");
|
2013-03-27 16:49:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
// this is how it normally renders, but it might not always do so.
|
|
|
|
static docstring const lyxstrikeout_style = from_ascii(
|
|
|
|
"del.strikeout {\n"
|
2015-05-17 15:27:12 +00:00
|
|
|
" text-decoration: line-through;\n"
|
|
|
|
"}\n");
|
2013-03-27 16:49:03 +00:00
|
|
|
|
|
|
|
|
2007-04-30 20:20:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// LaTeXFeatures
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-01-24 17:12:19 +00:00
|
|
|
|
2006-03-28 18:49:46 +00:00
|
|
|
LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
|
2019-03-16 11:59:34 +00:00
|
|
|
OutputParams const & r)
|
2016-10-17 01:25:35 +00:00
|
|
|
: buffer_(&b), params_(p), runparams_(r), in_float_(false),
|
|
|
|
in_deleted_inset_(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
|
|
|
|
2012-12-23 10:34:38 +00:00
|
|
|
LaTeXFeatures::LangPackage LaTeXFeatures::langPackage() const
|
2003-05-23 11:18:43 +00:00
|
|
|
{
|
2012-07-23 12:34:24 +00:00
|
|
|
string const local_lp = bufferParams().lang_package;
|
|
|
|
|
|
|
|
// Locally, custom is just stored as a string
|
|
|
|
// in bufferParams().lang_package.
|
|
|
|
if (local_lp != "auto"
|
|
|
|
&& local_lp != "babel"
|
|
|
|
&& local_lp != "default"
|
|
|
|
&& local_lp != "none")
|
|
|
|
return LANG_PACK_CUSTOM;
|
|
|
|
|
|
|
|
if (local_lp == "none")
|
|
|
|
return LANG_PACK_NONE;
|
|
|
|
|
2016-01-08 21:51:58 +00:00
|
|
|
/* If "auto" is selected, we load polyglossia with non-TeX fonts,
|
2012-07-23 12:34:24 +00:00
|
|
|
* else we select babel.
|
|
|
|
* If babel is selected (either directly or via the "auto"
|
|
|
|
* mechanism), we really do only require it if we have
|
|
|
|
* a language that needs it.
|
|
|
|
*/
|
|
|
|
bool const polyglossia_required =
|
2016-01-08 21:51:58 +00:00
|
|
|
params_.useNonTeXFonts
|
2011-02-03 14:17:31 +00:00
|
|
|
&& isAvailable("polyglossia")
|
2012-09-19 13:46:19 +00:00
|
|
|
&& !isProvided("babel")
|
2012-06-08 10:54:57 +00:00
|
|
|
&& this->hasOnlyPolyglossiaLanguages();
|
2015-05-17 15:27:12 +00:00
|
|
|
bool const babel_required =
|
2012-12-23 10:34:38 +00:00
|
|
|
!bufferParams().language->babel().empty()
|
2012-07-23 12:34:24 +00:00
|
|
|
|| !this->getBabelLanguages().empty();
|
|
|
|
|
|
|
|
if (local_lp == "auto") {
|
|
|
|
// polyglossia requirement has priority over babel
|
|
|
|
if (polyglossia_required)
|
|
|
|
return LANG_PACK_POLYGLOSSIA;
|
|
|
|
else if (babel_required)
|
|
|
|
return LANG_PACK_BABEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (local_lp == "babel") {
|
|
|
|
if (babel_required)
|
|
|
|
return LANG_PACK_BABEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (local_lp == "default") {
|
|
|
|
switch (lyxrc.language_package_selection) {
|
|
|
|
case LyXRC::LP_AUTO:
|
|
|
|
// polyglossia requirement has priority over babel
|
|
|
|
if (polyglossia_required)
|
|
|
|
return LANG_PACK_POLYGLOSSIA;
|
|
|
|
else if (babel_required)
|
|
|
|
return LANG_PACK_BABEL;
|
2012-08-08 09:27:37 +00:00
|
|
|
break;
|
2012-07-23 12:34:24 +00:00
|
|
|
case LyXRC::LP_BABEL:
|
|
|
|
if (babel_required)
|
|
|
|
return LANG_PACK_BABEL;
|
2012-08-08 09:27:37 +00:00
|
|
|
break;
|
2012-07-23 12:34:24 +00:00
|
|
|
case LyXRC::LP_CUSTOM:
|
|
|
|
return LANG_PACK_CUSTOM;
|
|
|
|
case LyXRC::LP_NONE:
|
|
|
|
return LANG_PACK_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return LANG_PACK_NONE;
|
2003-05-23 11:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-04-21 13:47:39 +00:00
|
|
|
void LaTeXFeatures::provide(string const & name)
|
|
|
|
{
|
|
|
|
provides_.insert(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-11 13:39:08 +00:00
|
|
|
void LaTeXFeatures::useLayout(docstring const & layoutname)
|
2014-07-05 12:37:55 +00:00
|
|
|
{
|
|
|
|
useLayout(layoutname, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LaTeXFeatures::useLayout(docstring const & layoutname, int level)
|
2001-11-19 15:34:11 +00:00
|
|
|
{
|
2002-07-20 20:47:54 +00:00
|
|
|
// Some code to avoid loops in dependency definition
|
|
|
|
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?
|
2011-12-03 22:15:11 +00:00
|
|
|
if (find(usedLayouts_.begin(), usedLayouts_.end(), layoutname)
|
2008-02-01 15:12:04 +00:00
|
|
|
!= usedLayouts_.end())
|
|
|
|
return;
|
|
|
|
|
2008-03-06 20:01:30 +00:00
|
|
|
Layout const & layout = tclass[layoutname];
|
2020-02-28 05:26:31 +00:00
|
|
|
require(layout.required());
|
2002-09-06 14:51:39 +00:00
|
|
|
|
2008-02-01 15:12:04 +00:00
|
|
|
if (!layout.depends_on().empty()) {
|
2014-07-05 12:37:55 +00:00
|
|
|
useLayout(layout.depends_on(), level + 1);
|
2002-07-20 20:47:54 +00:00
|
|
|
}
|
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
|
|
|
}
|
2001-11-19 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2009-06-03 23:44:31 +00:00
|
|
|
void LaTeXFeatures::useInsetLayout(InsetLayout const & lay)
|
|
|
|
{
|
|
|
|
docstring const & lname = lay.name();
|
|
|
|
DocumentClass const & tclass = params_.documentClass();
|
2009-07-14 18:29:39 +00:00
|
|
|
|
|
|
|
// this is a default inset layout, nothing useful here
|
|
|
|
if (!tclass.hasInsetLayout(lname))
|
2009-06-03 23:44:31 +00:00
|
|
|
return;
|
|
|
|
// Is this layout already in usedInsetLayouts?
|
2011-12-03 22:15:11 +00:00
|
|
|
if (find(usedInsetLayouts_.begin(), usedInsetLayouts_.end(), lname)
|
2009-06-03 23:44:31 +00:00
|
|
|
!= usedInsetLayouts_.end())
|
|
|
|
return;
|
|
|
|
|
2020-02-28 05:26:31 +00:00
|
|
|
require(lay.required());
|
2009-06-03 23:44:31 +00:00
|
|
|
usedInsetLayouts_.push_back(lname);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2012-09-19 13:46:19 +00:00
|
|
|
bool LaTeXFeatures::isProvided(string const & name) const
|
|
|
|
{
|
2018-04-21 14:28:15 +00:00
|
|
|
// Currently, this is only features provided by babel languages
|
|
|
|
// (such as textgreek)
|
2018-04-21 13:47:39 +00:00
|
|
|
if (provides_.find(name) != provides_.end())
|
|
|
|
return true;
|
|
|
|
|
2012-10-06 13:51:35 +00:00
|
|
|
if (params_.useNonTeXFonts)
|
|
|
|
return params_.documentClass().provides(name);
|
|
|
|
|
2017-02-25 11:49:49 +00:00
|
|
|
bool const ot1 = (params_.main_font_encoding() == "default"
|
|
|
|
|| params_.main_font_encoding() == "OT1");
|
2015-11-09 06:33:57 +00:00
|
|
|
bool const complete = (params_.fontsSans() == "default"
|
|
|
|
&& params_.fontsTypewriter() == "default");
|
|
|
|
bool const nomath = (params_.fontsMath() == "default");
|
2012-09-19 13:46:19 +00:00
|
|
|
return params_.documentClass().provides(name)
|
2012-09-22 08:59:53 +00:00
|
|
|
|| theLaTeXFonts().getLaTeXFont(
|
2015-11-09 06:33:57 +00:00
|
|
|
from_ascii(params_.fontsRoman())).provides(name, ot1,
|
2012-09-22 15:44:00 +00:00
|
|
|
complete,
|
|
|
|
nomath)
|
2012-09-22 08:59:53 +00:00
|
|
|
|| theLaTeXFonts().getLaTeXFont(
|
2015-11-09 06:33:57 +00:00
|
|
|
from_ascii(params_.fontsSans())).provides(name, ot1,
|
2012-09-22 15:44:00 +00:00
|
|
|
complete,
|
|
|
|
nomath)
|
2012-09-22 08:59:53 +00:00
|
|
|
|| theLaTeXFonts().getLaTeXFont(
|
2015-11-09 06:33:57 +00:00
|
|
|
from_ascii(params_.fontsTypewriter())).provides(name, ot1,
|
2012-09-23 15:40:44 +00:00
|
|
|
complete,
|
|
|
|
nomath)
|
|
|
|
|| theLaTeXFonts().getLaTeXFont(
|
2015-11-09 06:33:57 +00:00
|
|
|
from_ascii(params_.fontsMath())).provides(name, ot1,
|
2012-09-22 15:44:00 +00:00
|
|
|
complete,
|
|
|
|
nomath);
|
2012-09-19 13:46:19 +00:00
|
|
|
}
|
|
|
|
|
2012-10-27 13:45:27 +00:00
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
bool LaTeXFeatures::mustProvide(string const & name) const
|
|
|
|
{
|
2012-09-19 13:46:19 +00:00
|
|
|
return isRequired(name) && !isProvided(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
|
|
|
{
|
2009-05-28 08:59:25 +00:00
|
|
|
string::size_type const i = name.find("->");
|
|
|
|
if (i != string::npos) {
|
|
|
|
string const from = name.substr(0,i);
|
|
|
|
string const to = name.substr(i+2);
|
2009-06-28 22:12:16 +00:00
|
|
|
//LYXERR0("from=[" << from << "] to=[" << to << "]");
|
2009-05-28 08:59:25 +00:00
|
|
|
return theConverters().isReachable(from, to);
|
|
|
|
}
|
2011-11-06 17:03:59 +00:00
|
|
|
return LaTeXPackages::isAvailable(name);
|
2005-01-24 17:12:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-25 10:38:53 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void addSnippet(std::list<TexString> & list, TexString ts, bool allow_dupes)
|
2001-11-19 15:34:11 +00:00
|
|
|
{
|
2016-09-25 10:38:53 +00:00
|
|
|
if (allow_dupes ||
|
|
|
|
// test the absense of duplicates, i.e. elements with same str
|
|
|
|
none_of(list.begin(), list.end(), [&](TexString const & ts2){
|
|
|
|
return ts.str == ts2.str;
|
|
|
|
})
|
|
|
|
)
|
|
|
|
list.push_back(move(ts));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TexString getSnippets(std::list<TexString> const & list)
|
|
|
|
{
|
|
|
|
otexstringstream snip;
|
|
|
|
for (TexString const & ts : list)
|
|
|
|
snip << TexString(ts) << '\n';
|
|
|
|
return snip.release();
|
|
|
|
}
|
|
|
|
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace
|
2016-09-25 10:38:53 +00:00
|
|
|
|
|
|
|
|
2020-10-31 17:18:51 +00:00
|
|
|
void LaTeXFeatures::addPreambleSnippet(TexString snippet, bool allow_dupes)
|
2016-09-25 10:38:53 +00:00
|
|
|
{
|
2020-10-31 17:18:51 +00:00
|
|
|
addSnippet(preamble_snippets_, move(snippet), allow_dupes);
|
2016-09-25 10:38:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 17:18:51 +00:00
|
|
|
void LaTeXFeatures::addPreambleSnippet(docstring const & snippet, bool allow_dupes)
|
2016-09-25 10:38:53 +00:00
|
|
|
{
|
2020-10-31 17:18:51 +00:00
|
|
|
addSnippet(preamble_snippets_, TexString(snippet), allow_dupes);
|
2001-11-19 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2011-12-06 22:17:13 +00:00
|
|
|
void LaTeXFeatures::addCSSSnippet(std::string const & snippet)
|
|
|
|
{
|
2016-09-25 10:38:53 +00:00
|
|
|
addSnippet(css_snippets_, TexString(from_ascii(snippet)), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TexString LaTeXFeatures::getPreambleSnippets() const
|
|
|
|
{
|
|
|
|
return getSnippets(preamble_snippets_);
|
2011-12-06 22:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-25 10:38:53 +00:00
|
|
|
docstring LaTeXFeatures::getCSSSnippets() const
|
|
|
|
{
|
|
|
|
return getSnippets(css_snippets_).str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
2019-08-12 10:18:28 +00:00
|
|
|
if (!fl.floattype().empty()) {
|
|
|
|
if (fl.usesFloatPkg())
|
|
|
|
require("float");
|
2020-02-28 05:36:55 +00:00
|
|
|
if (!fl.required().empty()) {
|
|
|
|
vector<string> reqs = getVectorFromString(fl.required());
|
2020-03-14 22:05:49 +00:00
|
|
|
for (auto const & req : reqs)
|
2019-08-12 10:18:28 +00:00
|
|
|
require(req);
|
|
|
|
}
|
2002-01-10 10:05:45 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
2012-06-23 11:50:40 +00:00
|
|
|
if (!lang->babel().empty() || !lang->polyglossia().empty())
|
2007-05-05 19:18:34 +00:00
|
|
|
UsedLanguages_.insert(lang);
|
2020-02-28 05:36:55 +00:00
|
|
|
if (!lang->required().empty())
|
|
|
|
require(lang->required());
|
2018-04-21 13:47:39 +00:00
|
|
|
// currently only supported for Babel
|
|
|
|
if (!lang->provides().empty() && useBabel())
|
|
|
|
provide(lang->provides());
|
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");
|
2019-04-11 16:19:44 +00:00
|
|
|
// japanese babel language is special (tied to the pLaTeX engine).
|
2008-08-18 17:26:09 +00:00
|
|
|
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
|
|
|
|
2012-06-08 10:54:57 +00:00
|
|
|
bool LaTeXFeatures::hasOnlyPolyglossiaLanguages() const
|
2010-11-22 12:10:16 +00:00
|
|
|
{
|
2013-11-14 16:40:47 +00:00
|
|
|
// first the main language
|
|
|
|
if (params_.language->polyglossia().empty())
|
|
|
|
return false;
|
|
|
|
// now the secondary languages
|
2020-08-23 08:07:49 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
|
|
|
{
|
|
|
|
if (lang->polyglossia().empty())
|
2010-11-22 12:10:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-08 10:54:57 +00:00
|
|
|
bool LaTeXFeatures::hasPolyglossiaExclusiveLanguages() const
|
|
|
|
{
|
2013-11-14 16:40:47 +00:00
|
|
|
// first the main language
|
|
|
|
if (params_.language->isPolyglossiaExclusive())
|
|
|
|
return true;
|
|
|
|
// now the secondary languages
|
2020-08-23 08:07:49 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
|
|
|
{
|
|
|
|
if (lang->isPolyglossiaExclusive())
|
2012-06-08 10:54:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-27 07:59:01 +00:00
|
|
|
vector<string> LaTeXFeatures::getPolyglossiaExclusiveLanguages() const
|
|
|
|
{
|
|
|
|
vector<string> result;
|
|
|
|
// first the main language
|
|
|
|
if (params_.language->isPolyglossiaExclusive())
|
|
|
|
result.push_back(params_.language->display());
|
|
|
|
// now the secondary languages
|
2020-08-23 08:07:49 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
|
|
|
{
|
|
|
|
if (lang->isPolyglossiaExclusive())
|
|
|
|
result.push_back(lang->display());
|
2016-10-27 07:59:01 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vector<string> LaTeXFeatures::getBabelExclusiveLanguages() const
|
|
|
|
{
|
|
|
|
vector<string> result;
|
|
|
|
// first the main language
|
|
|
|
if (params_.language->isBabelExclusive())
|
|
|
|
result.push_back(params_.language->display());
|
|
|
|
// now the secondary languages
|
2020-08-23 08:07:49 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
|
|
|
{
|
|
|
|
if (lang->isBabelExclusive())
|
|
|
|
result.push_back(lang->display());
|
2016-10-27 07:59:01 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-23 11:50:40 +00:00
|
|
|
string LaTeXFeatures::getBabelLanguages() const
|
2001-11-19 15:34:11 +00:00
|
|
|
{
|
2020-08-23 08:04:07 +00:00
|
|
|
vector<string> blangs;
|
|
|
|
for (auto const & lang : UsedLanguages_) {
|
|
|
|
if (!lang->babel().empty())
|
|
|
|
blangs.push_back(lang->babel());
|
2007-05-06 20:26:02 +00:00
|
|
|
}
|
2020-08-23 08:04:07 +00:00
|
|
|
|
|
|
|
// Sort alphabetically to assure consistent order
|
|
|
|
// (the order itself does not matter apart from
|
|
|
|
// some exceptions, e.g. hebrew must come after
|
|
|
|
// arabic and farsi)
|
|
|
|
sort(blangs.begin(), blangs.end());
|
|
|
|
|
|
|
|
return getStringFromVector(blangs);
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
2016-11-02 16:07:49 +00:00
|
|
|
set<string> LaTeXFeatures::getPolyglossiaLanguages() const
|
2010-11-22 12:10:16 +00:00
|
|
|
{
|
2018-02-24 04:59:40 +00:00
|
|
|
set<string> langs;
|
2010-11-22 12:10:16 +00:00
|
|
|
|
2020-08-23 08:07:49 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
2016-11-02 16:07:49 +00:00
|
|
|
// We do not need the variants here
|
2020-08-23 08:07:49 +00:00
|
|
|
langs.insert(lang->polyglossia());
|
2018-02-24 04:59:40 +00:00
|
|
|
return langs;
|
2010-11-22 12:10:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-14 11:10:42 +00:00
|
|
|
string LaTeXFeatures::getActiveChars() const
|
|
|
|
{
|
|
|
|
string res;
|
|
|
|
// first the main language
|
|
|
|
res += params_.language->activeChars();
|
|
|
|
// now the secondary languages
|
2020-08-23 08:07:49 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
|
|
|
res += (lang->activeChars());
|
2019-08-14 11:10:42 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
|
2018-02-24 04:59:40 +00:00
|
|
|
set<string> encs;
|
|
|
|
for (auto const & lang : UsedLanguages_)
|
|
|
|
if (lang->encoding()->latexName() != doc_encoding &&
|
2019-04-11 16:19:44 +00:00
|
|
|
lang->encoding()->package() == Encoding::inputenc)
|
2018-02-24 04:59:40 +00:00
|
|
|
encs.insert(lang->encoding()->latexName());
|
|
|
|
return encs;
|
2001-11-19 15:34:11 +00:00
|
|
|
}
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2015-01-24 13:02:16 +00:00
|
|
|
|
2018-04-21 13:00:42 +00:00
|
|
|
void LaTeXFeatures::getFontEncodings(vector<string> & encs, bool const onlylangs) const
|
2015-01-24 13:02:16 +00:00
|
|
|
{
|
2018-04-21 13:00:42 +00:00
|
|
|
if (!onlylangs) {
|
|
|
|
// these must be loaded if glyphs of this script are used
|
|
|
|
// unless a language providing them is used in the document
|
|
|
|
if (mustProvide("textgreek")
|
|
|
|
&& find(encs.begin(), encs.end(), "LGR") == encs.end())
|
|
|
|
encs.insert(encs.begin(), "LGR");
|
2019-05-14 15:12:46 +00:00
|
|
|
if ((mustProvide("textcyrillic") || mustProvide("textschwa"))
|
2018-04-21 13:00:42 +00:00
|
|
|
&& find(encs.begin(), encs.end(), "T2A") == encs.end())
|
|
|
|
encs.insert(encs.begin(), "T2A");
|
|
|
|
}
|
2018-02-24 04:59:40 +00:00
|
|
|
|
2020-08-23 08:07:49 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
|
|
|
{
|
2018-04-23 10:59:57 +00:00
|
|
|
vector<string> extraencs =
|
|
|
|
getVectorFromString(lang->fontenc(buffer().masterParams()));
|
|
|
|
for (auto const & extra : extraencs) {
|
|
|
|
if (extra != "none" && find(encs.begin(), encs.end(), extra) == encs.end())
|
|
|
|
encs.insert(encs.begin(), extra);
|
2015-01-24 13:02:16 +00:00
|
|
|
}
|
2018-04-23 10:59:57 +00:00
|
|
|
}
|
2015-01-24 13:02:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-15 18:56:55 +00:00
|
|
|
|
|
|
|
bool LaTeXFeatures::hasRTLLanguage() const
|
|
|
|
{
|
|
|
|
if (params_.language->rightToLeft())
|
|
|
|
return true;
|
|
|
|
for (auto const & lang : UsedLanguages_)
|
|
|
|
if (lang->rightToLeft())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-07 16:01:05 +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",
|
2018-04-13 15:46:37 +00:00
|
|
|
"cprotect",
|
2002-01-10 10:05:45 +00:00
|
|
|
"longtable",
|
|
|
|
"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",
|
2010-10-13 12:36:53 +00:00
|
|
|
"refstyle",
|
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",
|
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
|
|
|
"fancybox",
|
2004-03-07 14:33:17 +00:00
|
|
|
"calc",
|
2007-09-12 08:15:33 +00:00
|
|
|
"units",
|
2006-06-03 16:46:27 +00:00
|
|
|
"framed",
|
2007-05-13 15:17:57 +00:00
|
|
|
"soul",
|
2019-01-11 15:40:41 +00:00
|
|
|
"dingbat",
|
2007-05-28 16:04:01 +00:00
|
|
|
"bbding",
|
|
|
|
"ifsym",
|
|
|
|
"txfonts",
|
2011-10-20 17:30:04 +00:00
|
|
|
"pxfonts",
|
|
|
|
"mathdesign",
|
2007-05-30 23:22:58 +00:00
|
|
|
"mathrsfs",
|
2011-10-20 19:55:13 +00:00
|
|
|
"mathabx",
|
2011-12-18 17:50:43 +00:00
|
|
|
"mathtools",
|
2013-02-27 12:12:03 +00:00
|
|
|
// "cancel",
|
2007-05-30 23:22:58 +00:00
|
|
|
"ascii",
|
2007-10-13 19:18:36 +00:00
|
|
|
"url",
|
2008-01-07 16:59:10 +00:00
|
|
|
"csquotes",
|
|
|
|
"enumitem",
|
2008-01-07 17:32:47 +00:00
|
|
|
"endnotes",
|
2019-08-13 05:30:20 +00:00
|
|
|
"enotez",
|
2010-12-09 01:19:13 +00:00
|
|
|
"hhline",
|
2008-01-10 04:14:22 +00:00
|
|
|
"ifthen",
|
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",
|
2010-02-11 01:07:54 +00:00
|
|
|
"slashed",
|
2013-05-30 15:55:21 +00:00
|
|
|
"multicol",
|
2010-11-18 22:30:28 +00:00
|
|
|
"multirow",
|
2013-05-30 15:55:21 +00:00
|
|
|
"tfrupee",
|
2013-05-30 16:15:44 +00:00
|
|
|
"shapepar",
|
2014-01-26 18:23:40 +00:00
|
|
|
"rsphrase",
|
2015-05-28 23:47:46 +00:00
|
|
|
"hpstatement",
|
2014-07-02 11:48:01 +00:00
|
|
|
"algorithm2e",
|
|
|
|
"sectionbox",
|
2014-07-03 09:30:56 +00:00
|
|
|
"tcolorbox",
|
2014-08-31 12:38:28 +00:00
|
|
|
"pdfcomment",
|
2014-08-31 12:49:30 +00:00
|
|
|
"fixme",
|
2015-04-20 16:14:42 +00:00
|
|
|
"todonotes",
|
2015-11-01 10:00:23 +00:00
|
|
|
"forest",
|
2016-12-18 22:41:43 +00:00
|
|
|
"varwidth",
|
2018-04-18 14:20:19 +00:00
|
|
|
"afterpage",
|
2018-06-24 08:05:15 +00:00
|
|
|
"tabularx",
|
2019-12-28 12:43:17 +00:00
|
|
|
"tikz",
|
2018-09-23 10:26:43 +00:00
|
|
|
"xltabular",
|
|
|
|
"chessboard",
|
2019-06-23 10:59:56 +00:00
|
|
|
"xskak",
|
|
|
|
"pict2e",
|
2019-08-15 13:15:59 +00:00
|
|
|
"drs",
|
2020-06-11 14:42:31 +00:00
|
|
|
"environ",
|
2020-07-28 16:01:38 +00:00
|
|
|
"dsfont"
|
2002-01-10 10:05:45 +00:00
|
|
|
};
|
|
|
|
|
2013-01-04 22:57:40 +00:00
|
|
|
char const * bibliofeatures[] = {
|
|
|
|
// Known bibliography packages (will be loaded before natbib)
|
|
|
|
"achicago",
|
|
|
|
"apacite",
|
|
|
|
"apalike",
|
|
|
|
"astron",
|
|
|
|
"authordate1-4",
|
2013-05-20 18:29:15 +00:00
|
|
|
"babelbib",
|
|
|
|
"bibgerm",
|
2017-02-04 18:23:46 +00:00
|
|
|
"chapterbib",
|
2013-01-04 22:57:40 +00:00
|
|
|
"chicago",
|
2013-05-20 18:29:15 +00:00
|
|
|
"chscite",
|
2013-01-04 22:57:40 +00:00
|
|
|
"harvard",
|
|
|
|
"mslapa",
|
|
|
|
"named"
|
|
|
|
};
|
|
|
|
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace
|
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");
|
2010-11-26 18:42:53 +00:00
|
|
|
if (params_.graphics_driver == "default"
|
|
|
|
|| params_.graphics_driver == "none")
|
2008-09-29 19:18:00 +00:00
|
|
|
colors << "\\usepackage{" << package << "}\n";
|
|
|
|
else
|
|
|
|
colors << "\\usepackage["
|
2010-11-26 18:42:53 +00:00
|
|
|
<< params_.graphics_driver
|
2008-09-29 19:18:00 +00:00
|
|
|
<< "]{" << package << "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// pdfcolmk must be loaded after color
|
|
|
|
if (mustProvide("pdfcolmk"))
|
|
|
|
colors << "\\usepackage{pdfcolmk}\n";
|
|
|
|
|
2010-03-31 00:46:50 +00:00
|
|
|
// the following 3 color commands must be set after color
|
|
|
|
// is loaded and before pdfpages, therefore add the command
|
|
|
|
// here define the set color
|
2009-04-11 21:40:11 +00:00
|
|
|
if (mustProvide("pagecolor")) {
|
|
|
|
colors << "\\definecolor{page_backgroundcolor}{rgb}{";
|
|
|
|
colors << outputLaTeXColor(params_.backgroundcolor) << "}\n";
|
|
|
|
// set the page color
|
|
|
|
colors << "\\pagecolor{page_backgroundcolor}\n";
|
|
|
|
}
|
|
|
|
|
2010-04-02 23:39:36 +00:00
|
|
|
if (mustProvide("fontcolor")) {
|
|
|
|
colors << "\\definecolor{document_fontcolor}{rgb}{";
|
|
|
|
colors << outputLaTeXColor(params_.fontcolor) << "}\n";
|
|
|
|
// set the color
|
|
|
|
colors << "\\color{document_fontcolor}\n";
|
|
|
|
}
|
|
|
|
|
2010-03-31 00:46:50 +00:00
|
|
|
if (mustProvide("lyxgreyedout")) {
|
|
|
|
colors << "\\definecolor{note_fontcolor}{rgb}{";
|
|
|
|
colors << outputLaTeXColor(params_.notefontcolor) << "}\n";
|
|
|
|
// the color will be set together with the definition of
|
2010-04-02 23:39:36 +00:00
|
|
|
// the lyxgreyedout environment (see lyxgreyedout_def)
|
2010-03-31 00:46:50 +00:00
|
|
|
}
|
|
|
|
|
2010-04-08 00:14:08 +00:00
|
|
|
// color for shaded boxes
|
|
|
|
if (isRequired("framed") && mustProvide("color")) {
|
|
|
|
colors << "\\definecolor{shadecolor}{rgb}{";
|
|
|
|
colors << outputLaTeXColor(params_.boxbgcolor) << "}\n";
|
|
|
|
// this color is automatically used by the LaTeX-package "framed"
|
|
|
|
}
|
|
|
|
|
2008-09-29 19:18:00 +00:00
|
|
|
return colors.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-21 11:10:06 +00:00
|
|
|
string const LaTeXFeatures::getPackageOptions() const
|
|
|
|
{
|
|
|
|
ostringstream packageopts;
|
|
|
|
// Output all the package option stuff we have been asked to do.
|
2020-12-03 19:51:25 +00:00
|
|
|
for (auto const & p : params_.documentClass().packageOptions())
|
|
|
|
if (mustProvide(p.first))
|
|
|
|
packageopts << "\\PassOptionsToPackage{" << p.second << "}"
|
|
|
|
<< "{" << p.first << "}\n";
|
2014-12-21 11:10:06 +00:00
|
|
|
return packageopts.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;
|
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,
|
2010-11-21 18:07:04 +00:00
|
|
|
// also unknown packages can be requested. They are silently
|
2008-01-07 16:59:10 +00:00
|
|
|
// 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}
|
2020-10-09 06:04:20 +00:00
|
|
|
for (char const * feature : simplefeatures) {
|
|
|
|
if (mustProvide(feature))
|
|
|
|
packages << "\\usepackage{" << feature << "}\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
|
|
|
|
2020-01-13 07:59:26 +00:00
|
|
|
if (mustProvide("changebar")) {
|
2020-01-11 15:51:00 +00:00
|
|
|
packages << "\\usepackage";
|
2020-11-30 22:00:40 +00:00
|
|
|
if (runparams_.flavor == Flavor::LaTeX
|
|
|
|
|| runparams_.flavor == Flavor::DviLuaTeX)
|
2020-01-11 15:51:00 +00:00
|
|
|
packages << "[dvips]";
|
|
|
|
packages << "{changebar}\n";
|
2019-12-24 17:12:22 +00:00
|
|
|
}
|
|
|
|
|
2018-07-25 16:01:22 +00:00
|
|
|
if (mustProvide("footnote")) {
|
|
|
|
if (isRequired("hyperref"))
|
|
|
|
packages << "\\usepackage{footnotehyper}\n";
|
|
|
|
else
|
|
|
|
packages << "\\usepackage{footnote}\n";
|
|
|
|
}
|
|
|
|
|
2018-04-18 11:22:29 +00:00
|
|
|
// [pdf]lscape is used to rotate longtables
|
|
|
|
if (mustProvide("lscape")) {
|
2020-11-30 22:00:40 +00:00
|
|
|
if (runparams_.flavor == Flavor::LaTeX
|
|
|
|
|| runparams_.flavor == Flavor::DviLuaTeX)
|
2018-04-18 11:22:29 +00:00
|
|
|
packages << "\\usepackage{lscape}\n";
|
|
|
|
else
|
|
|
|
packages << "\\usepackage{pdflscape}\n";
|
|
|
|
}
|
|
|
|
|
2013-12-14 14:09:23 +00:00
|
|
|
// The tipa package and its extensions (tipx, tone) must not
|
|
|
|
// be loaded with non-TeX fonts, since fontspec includes the
|
2013-12-14 08:13:17 +00:00
|
|
|
// respective macros
|
|
|
|
if (mustProvide("tipa") && !params_.useNonTeXFonts)
|
|
|
|
packages << "\\usepackage{tipa}\n";
|
|
|
|
if (mustProvide("tipx") && !params_.useNonTeXFonts)
|
|
|
|
packages << "\\usepackage{tipx}\n";
|
2016-09-10 08:50:06 +00:00
|
|
|
if (mustProvide("extraipa") && !params_.useNonTeXFonts)
|
|
|
|
packages << "\\usepackage{extraipa}\n";
|
2013-12-14 08:13:17 +00:00
|
|
|
if (mustProvide("tone") && !params_.useNonTeXFonts)
|
|
|
|
packages << "\\usepackage{tone}\n";
|
|
|
|
|
2013-09-01 08:21:21 +00:00
|
|
|
// if fontspec or newtxmath is used, AMS packages have to be loaded
|
|
|
|
// before fontspec (in BufferParams)
|
2011-10-18 19:32:02 +00:00
|
|
|
string const amsPackages = loadAMSPackages();
|
2017-02-25 11:49:49 +00:00
|
|
|
bool const ot1 = (params_.main_font_encoding() == "default"
|
|
|
|
|| params_.main_font_encoding() == "OT1");
|
2013-09-01 08:21:21 +00:00
|
|
|
bool const use_newtxmath =
|
2015-11-09 06:33:57 +00:00
|
|
|
theLaTeXFonts().getLaTeXFont(from_ascii(params_.fontsMath())).getUsedPackage(
|
2013-09-01 08:21:21 +00:00
|
|
|
ot1, false, false) == "newtxmath";
|
2015-05-17 15:27:12 +00:00
|
|
|
|
2013-09-01 08:21:21 +00:00
|
|
|
if (!params_.useNonTeXFonts && !use_newtxmath && !amsPackages.empty())
|
2011-10-18 19:32:02 +00:00
|
|
|
packages << amsPackages;
|
2010-12-08 18:42:10 +00:00
|
|
|
|
2013-09-01 08:21:21 +00:00
|
|
|
if (mustProvide("cancel") &&
|
|
|
|
params_.use_package("cancel") != BufferParams::package_off)
|
|
|
|
packages << "\\usepackage{cancel}\n";
|
2015-05-17 15:27:12 +00:00
|
|
|
|
2015-07-06 12:10:34 +00:00
|
|
|
// marvosym and bbding both define the \Cross macro
|
|
|
|
if (mustProvide("marvosym")) {
|
|
|
|
if (mustProvide("bbding"))
|
|
|
|
packages << "\\let\\Cross\\relax\n";
|
|
|
|
packages << "\\usepackage{marvosym}\n";
|
|
|
|
}
|
|
|
|
|
2008-09-26 15:53:15 +00:00
|
|
|
// accents must be loaded after amsmath
|
2012-01-03 20:51:07 +00:00
|
|
|
if (mustProvide("accents") &&
|
|
|
|
params_.use_package("accents") != BufferParams::package_off)
|
2008-09-26 15:53:15 +00:00
|
|
|
packages << "\\usepackage{accents}\n";
|
|
|
|
|
2009-06-18 20:04:27 +00:00
|
|
|
// mathdots must be loaded after amsmath
|
2010-08-31 23:34:54 +00:00
|
|
|
if (mustProvide("mathdots") &&
|
2012-01-03 20:51:07 +00:00
|
|
|
params_.use_package("mathdots") != BufferParams::package_off)
|
2009-06-18 20:04:27 +00:00
|
|
|
packages << "\\usepackage{mathdots}\n";
|
|
|
|
|
|
|
|
// yhmath must be loaded after amsmath
|
2012-01-03 20:51:07 +00:00
|
|
|
if (mustProvide("yhmath") &&
|
|
|
|
params_.use_package("yhmath") != BufferParams::package_off)
|
2009-06-18 20:04:27 +00:00
|
|
|
packages << "\\usepackage{yhmath}\n";
|
|
|
|
|
2012-12-15 12:02:40 +00:00
|
|
|
// stmaryrd must be loaded after amsmath
|
|
|
|
if (mustProvide("stmaryrd") &&
|
|
|
|
params_.use_package("stmaryrd") != BufferParams::package_off)
|
|
|
|
packages << "\\usepackage{stmaryrd}\n";
|
|
|
|
|
2012-12-28 18:51:28 +00:00
|
|
|
if (mustProvide("stackrel") &&
|
|
|
|
params_.use_package("stackrel") != BufferParams::package_off)
|
|
|
|
packages << "\\usepackage{stackrel}\n";
|
|
|
|
|
2011-08-10 03:37:33 +00:00
|
|
|
if (mustProvide("undertilde") &&
|
2012-01-03 20:51:07 +00:00
|
|
|
params_.use_package("undertilde") != BufferParams::package_off)
|
2011-08-10 03:37:33 +00:00
|
|
|
packages << "\\usepackage{undertilde}\n";
|
|
|
|
|
2008-09-29 19:18:00 +00:00
|
|
|
// [x]color and pdfcolmk are handled in getColorOptions() above
|
2011-12-03 22:15:11 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// makeidx.sty
|
2009-04-16 07:29:01 +00:00
|
|
|
if (isRequired("makeidx") || isRequired("splitidx")) {
|
2012-09-19 13:46:19 +00:00
|
|
|
if (!isProvided("makeidx") && !isRequired("splitidx"))
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\usepackage{makeidx}\n";
|
2012-09-19 13:46:19 +00:00
|
|
|
if (mustProvide("splitidx"))
|
2009-04-16 07:29:01 +00:00
|
|
|
packages << "\\usepackage{splitidx}\n";
|
2001-05-08 17:08:44 +00:00
|
|
|
packages << "\\makeindex\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
// graphicx.sty
|
2010-11-26 18:42:53 +00:00
|
|
|
if (mustProvide("graphicx") && params_.graphics_driver != "none") {
|
|
|
|
if (params_.graphics_driver == "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["
|
2010-11-26 18:42:53 +00:00
|
|
|
<< params_.graphics_driver
|
2001-05-08 17:08:44 +00:00
|
|
|
<< "]{graphicx}\n";
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2019-08-14 13:16:10 +00:00
|
|
|
// These must be loaded after graphicx, since they try
|
|
|
|
// to load graphicx without options
|
|
|
|
if (mustProvide("rotating"))
|
|
|
|
packages << "\\usepackage{rotating}\n";
|
|
|
|
if (mustProvide("rotfloat"))
|
|
|
|
packages << "\\usepackage{rotfloat}\n";
|
2020-04-17 07:12:51 +00:00
|
|
|
// and this must be loaded after rotating
|
|
|
|
if (mustProvide("tablefootnote"))
|
|
|
|
packages << "\\usepackage{tablefootnote}\n";
|
2019-08-14 13:16: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
|
2012-09-19 13:46:19 +00:00
|
|
|
if (mustProvide("setspace") && !isProvided("SetSpace"))
|
2008-08-19 07:06:51 +00:00
|
|
|
packages << "\\usepackage{setspace}\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2014-09-10 20:01:29 +00:00
|
|
|
// we need to assure that mhchem is loaded before esint and every other
|
|
|
|
// package that redefines command of amsmath because mhchem loads amlatex
|
2013-07-16 21:16:09 +00:00
|
|
|
// (this info is from the author of mhchem from June 2013)
|
|
|
|
if (mustProvide("mhchem") &&
|
|
|
|
params_.use_package("mhchem") != BufferParams::package_off)
|
|
|
|
packages << "\\PassOptionsToPackage{version=3}{mhchem}\n"
|
|
|
|
"\\usepackage{mhchem}\n";
|
|
|
|
|
2014-09-10 20:01:29 +00:00
|
|
|
// wasysym is a simple feature, but it must be after amsmath if both
|
|
|
|
// are used
|
|
|
|
// wasysym redefines some integrals (e.g. iint) from amsmath. That
|
|
|
|
// leads to inconsistent integrals. We only load this package if
|
|
|
|
// 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.
|
|
|
|
// See http://www.lyx.org/trac/ticket/1942
|
|
|
|
if (mustProvide("wasysym") &&
|
|
|
|
params_.use_package("wasysym") != BufferParams::package_off &&
|
|
|
|
(params_.use_package("esint") != BufferParams::package_off || !isRequired("esint")))
|
|
|
|
packages << "\\usepackage{wasysym}\n";
|
|
|
|
|
2013-07-16 21:16:09 +00:00
|
|
|
// esint must be after amsmath (and packages requiring amsmath, like mhchem)
|
|
|
|
// and wasysym, since it will redeclare inconsistent integral symbols
|
2011-10-18 19:32:02 +00:00
|
|
|
if (mustProvide("esint") &&
|
2012-01-03 20:51:07 +00:00
|
|
|
params_.use_package("esint") != BufferParams::package_off)
|
2006-11-13 17:35:18 +00:00
|
|
|
packages << "\\usepackage{esint}\n";
|
|
|
|
|
2013-01-04 22:57:40 +00:00
|
|
|
// Known bibliography packages (simple \usepackage{package})
|
2020-10-09 06:04:20 +00:00
|
|
|
for (char const * feature : bibliofeatures) {
|
|
|
|
if (mustProvide(feature))
|
|
|
|
packages << "\\usepackage{" << feature << "}\n";
|
2013-01-04 22:57:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compatibility between achicago and natbib
|
|
|
|
if (mustProvide("achicago") && mustProvide("natbib"))
|
|
|
|
packages << "\\let\\achicagobib\\thebibliography\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.
|
2018-02-08 12:25:19 +00:00
|
|
|
if (mustProvide("natbib")
|
|
|
|
&& !isProvided("natbib-internal")
|
|
|
|
&& !isProvided("biblatex")
|
|
|
|
&& !isProvided("biblatex-natbib")
|
|
|
|
&& !isProvided("jurabib")) {
|
2001-07-26 09:47:36 +00:00
|
|
|
packages << "\\usepackage[";
|
2012-01-09 13:16:38 +00:00
|
|
|
if (params_.citeEngineType() == ENGINE_TYPE_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";
|
2017-01-13 17:23:42 +00:00
|
|
|
if (!params_.biblio_opts.empty())
|
|
|
|
packages << ',' << params_.biblio_opts;
|
2001-07-26 09:47:36 +00:00
|
|
|
packages << "]{natbib}\n";
|
2001-07-19 14:12:37 +00:00
|
|
|
}
|
2004-07-24 10:55:30 +00:00
|
|
|
|
2013-01-04 22:57:40 +00:00
|
|
|
// Compatibility between achicago and natbib
|
|
|
|
if (mustProvide("achicago") && mustProvide("natbib")) {
|
|
|
|
packages << "\\let\\thebibliography\\achicagobib\n";
|
|
|
|
packages << "\\let\\SCcite\\astroncite\n";
|
|
|
|
packages << "\\let\\UnexpandableProtect\\protect\n";
|
|
|
|
}
|
|
|
|
|
2004-07-23 16:03:39 +00:00
|
|
|
// jurabib -- we need version 0.6 at least.
|
2018-02-08 12:25:19 +00:00
|
|
|
if (mustProvide("jurabib")
|
|
|
|
&& !isProvided("natbib-internal")
|
|
|
|
&& !isProvided("natbib")
|
|
|
|
&& !isProvided("biblatex")
|
|
|
|
&& !isProvided("biblatex-natbib")) {
|
2017-01-13 17:23:42 +00:00
|
|
|
packages << "\\usepackage";
|
|
|
|
if (!params_.biblio_opts.empty())
|
|
|
|
packages << '[' << params_.biblio_opts << ']';
|
|
|
|
packages << "{jurabib}[2004/01/25]\n";
|
|
|
|
}
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2013-05-20 18:29:15 +00:00
|
|
|
// opcit -- we pass custombst as we output \bibliographystyle ourselves
|
|
|
|
if (mustProvide("opcit")) {
|
|
|
|
if (isRequired("hyperref"))
|
|
|
|
packages << "\\usepackage[custombst,hyperref]{opcit}\n";
|
|
|
|
else
|
|
|
|
packages << "\\usepackage[custombst]{opcit}\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
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
if (mustProvide("xy"))
|
2006-10-31 19:10:30 +00:00
|
|
|
packages << "\\usepackage[all]{xy}\n";
|
|
|
|
|
2010-09-19 22:12:06 +00:00
|
|
|
if (mustProvide("feyn"))
|
|
|
|
packages << "\\usepackage{feyn}\n"; //Diagram
|
|
|
|
|
2009-01-12 08:01:28 +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
|
|
|
|
2010-11-28 10:46:47 +00:00
|
|
|
// fixltx2e provides subscript
|
|
|
|
if (mustProvide("subscript") && !isRequired("fixltx2e"))
|
|
|
|
packages << "\\usepackage{subscript}\n";
|
|
|
|
|
2014-11-14 19:20:35 +00:00
|
|
|
// footmisc must be loaded after setspace
|
|
|
|
// Set options here, load the package after the user preamble to
|
|
|
|
// avoid problems with manual loaded footmisc.
|
|
|
|
if (mustProvide("footmisc"))
|
|
|
|
packages << "\\PassOptionsToPackage{stable}{footmisc}\n";
|
|
|
|
|
2016-06-03 05:40:21 +00:00
|
|
|
if (mustProvide("microtype")){
|
|
|
|
packages << "\\usepackage{microtype}\n";
|
|
|
|
}
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
return packages.str();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-25 10:38:53 +00:00
|
|
|
TexString LaTeXFeatures::getMacros() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2016-09-25 10:38:53 +00:00
|
|
|
otexstringstream macros;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2009-12-03 21:06:41 +00:00
|
|
|
if (!preamble_snippets_.empty()) {
|
2003-09-04 17:01:00 +00:00
|
|
|
macros << '\n';
|
2016-09-25 10:37:40 +00:00
|
|
|
macros << getPreambleSnippets();
|
2009-12-03 21:06:41 +00:00
|
|
|
}
|
2003-09-04 17:01:00 +00:00
|
|
|
|
2017-12-16 15:11:25 +00:00
|
|
|
if (mustProvide("xetexdashbreakstate"))
|
|
|
|
macros << "\\XeTeXdashbreakstate 0" << '\n';
|
|
|
|
|
2009-12-03 20:19:15 +00:00
|
|
|
if (mustProvide("papersize")) {
|
2020-11-30 22:00:40 +00:00
|
|
|
if (runparams_.flavor == Flavor::LaTeX
|
|
|
|
|| runparams_.flavor == Flavor::DviLuaTeX)
|
2008-07-01 12:46:46 +00:00
|
|
|
macros << papersizedvi_def << '\n';
|
2020-11-30 22:00:40 +00:00
|
|
|
else if (runparams_.flavor == Flavor::LuaTeX)
|
2016-07-09 14:45:27 +00:00
|
|
|
macros << papersizepdflua_def << '\n';
|
2008-07-01 12:46:46 +00:00
|
|
|
else
|
|
|
|
macros << papersizepdf_def << '\n';
|
2008-11-15 13:56:39 +00:00
|
|
|
}
|
2008-07-01 12:46:46 +00:00
|
|
|
|
2011-01-10 17:27:56 +00:00
|
|
|
if (mustProvide("LyX")) {
|
2019-03-07 16:01:05 +00:00
|
|
|
macros << "\\providecommand{\\LyX}";
|
|
|
|
// open conditional wrappers
|
|
|
|
if (runparams_.use_polyglossia && hasRTLLanguage())
|
|
|
|
macros << "{\\@ensure@LTR";
|
2011-01-10 17:27:56 +00:00
|
|
|
if (isRequired("hyperref"))
|
2019-03-07 16:01:05 +00:00
|
|
|
macros << "{\\texorpdfstring";
|
|
|
|
if (useBabel())
|
2019-03-27 08:52:44 +00:00
|
|
|
macros << "{\\ensureascii";
|
2019-03-07 16:01:05 +00:00
|
|
|
// main definition
|
|
|
|
macros << lyx_def;
|
|
|
|
// close conditional wrappers
|
|
|
|
if (useBabel())
|
|
|
|
macros << '}';
|
|
|
|
if (isRequired("hyperref"))
|
|
|
|
macros << "{LyX}}";
|
2018-07-15 18:56:55 +00:00
|
|
|
if (runparams_.use_polyglossia && hasRTLLanguage())
|
2019-03-07 16:01:05 +00:00
|
|
|
macros << '}';
|
|
|
|
macros << '\n';
|
2011-01-10 17:27:56 +00:00
|
|
|
}
|
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
|
|
|
|
2021-01-04 21:36:01 +00:00
|
|
|
if (mustProvide("aastex_case"))
|
|
|
|
macros << aastex_case_def << '\n';
|
|
|
|
|
2017-03-06 13:49:30 +00:00
|
|
|
if (mustProvide("lyxzerowidthspace"))
|
|
|
|
macros << lyxZWSP_def << '\n';
|
|
|
|
|
2010-11-22 12:10:16 +00:00
|
|
|
if (!usePolyglossia() && mustProvide("textgreek")) {
|
2016-12-18 22:41:43 +00:00
|
|
|
// ensure LGR font encoding is defined also if fontenc is not loaded by LyX
|
2017-02-25 11:49:49 +00:00
|
|
|
if (params_.main_font_encoding() == "default")
|
2015-07-11 13:39:02 +00:00
|
|
|
macros << textgreek_LGR_def;
|
2015-08-26 22:04:19 +00:00
|
|
|
macros << textgreek_def << '\n';
|
2010-01-23 17:24:58 +00:00
|
|
|
}
|
2007-10-12 18:21:51 +00:00
|
|
|
|
2018-04-21 14:28:15 +00:00
|
|
|
if (!usePolyglossia() && mustProvide("textcyrillic")) {
|
2015-10-19 16:21:59 +00:00
|
|
|
// ensure T2A font encoding is set up also if fontenc is not loaded by LyX
|
2017-02-25 11:49:49 +00:00
|
|
|
if (params_.main_font_encoding() == "default")
|
2015-07-14 12:47:44 +00:00
|
|
|
macros << textcyr_T2A_def;
|
2007-10-12 18:21:51 +00:00
|
|
|
macros << textcyr_def << '\n';
|
2015-10-19 16:21:59 +00:00
|
|
|
}
|
2007-10-12 18:21:51 +00:00
|
|
|
|
2016-12-18 22:41:43 +00:00
|
|
|
// non-standard text accents:
|
2015-07-12 14:21:25 +00:00
|
|
|
if (mustProvide("textcommaabove") || mustProvide("textcommaaboveright") ||
|
2018-04-28 11:31:29 +00:00
|
|
|
mustProvide("textcommabelow") || mustProvide("textbaltic"))
|
2015-07-12 14:21:25 +00:00
|
|
|
macros << lyxaccent_def;
|
|
|
|
|
2018-04-28 11:31:29 +00:00
|
|
|
if (mustProvide("textcommabelow") || mustProvide("textbaltic"))
|
2015-07-12 14:21:25 +00:00
|
|
|
macros << textcommabelow_def << '\n';
|
|
|
|
|
2018-04-28 11:31:29 +00:00
|
|
|
if (mustProvide("textcommaabove") || mustProvide("textbaltic"))
|
2015-07-12 14:21:25 +00:00
|
|
|
macros << textcommaabove_def << '\n';
|
|
|
|
|
|
|
|
if (mustProvide("textcommaaboveright"))
|
|
|
|
macros << textcommaaboveright_def << '\n';
|
|
|
|
|
2018-04-28 11:31:29 +00:00
|
|
|
if (mustProvide("textbaltic"))
|
2015-07-12 14:21:25 +00:00
|
|
|
macros << textbaltic_def << '\n';
|
|
|
|
|
2019-05-14 15:12:46 +00:00
|
|
|
if (mustProvide("textschwa"))
|
|
|
|
macros << textschwa_def << '\n';
|
|
|
|
|
2016-12-18 22:41:43 +00:00
|
|
|
// split-level fractions
|
|
|
|
if (mustProvide("xfrac") || mustProvide("smallLetterFrac"))
|
|
|
|
macros << xfrac_def << '\n';
|
|
|
|
|
|
|
|
if (mustProvide("smallLetterFrac"))
|
|
|
|
macros << smallLetterFrac_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';
|
2016-12-21 14:17:30 +00:00
|
|
|
if (mustProvide("textquotedbl"))
|
|
|
|
macros << textquotedbl_def << '\n';
|
|
|
|
if (mustProvide("textquotesinglep")) {
|
2020-11-30 22:00:40 +00:00
|
|
|
if (runparams_.flavor == Flavor::XeTeX)
|
2016-12-21 14:17:30 +00:00
|
|
|
macros << textquotesinglep_xetex_def << '\n';
|
|
|
|
else
|
|
|
|
macros << textquotesinglep_luatex_def << '\n';
|
|
|
|
}
|
|
|
|
if (mustProvide("textquotedblp")) {
|
2020-11-30 22:00:40 +00:00
|
|
|
if (runparams_.flavor == Flavor::XeTeX)
|
2016-12-21 14:17:30 +00:00
|
|
|
macros << textquotedblp_xetex_def << '\n';
|
|
|
|
else
|
|
|
|
macros << textquotedblp_luatex_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;
|
2016-01-26 20:33:46 +00:00
|
|
|
if (mustProvide("NeedLyXFootnoteCode"))
|
|
|
|
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;
|
|
|
|
|
2021-01-22 18:16:43 +00:00
|
|
|
if (mustProvide("cellvarwidth"))
|
|
|
|
macros << cellvarwidth_def;
|
|
|
|
|
2010-03-31 00:46:50 +00:00
|
|
|
// greyed-out environment (note inset)
|
|
|
|
// the color is specified in the routine
|
|
|
|
// getColorOptions() to avoid LaTeX-package clashes
|
2021-01-20 10:04:16 +00:00
|
|
|
if (mustProvide("lyxgreyedout"))
|
|
|
|
// We need different version for RTL (#8647), with change tracking (#12025)
|
|
|
|
// and for some specific engine/language package combinations
|
|
|
|
macros << lyxgreyedoutDef(hasRTLLanguage(), mustProvide("ct-xcolor-ulem"),
|
|
|
|
(runparams_.flavor == Flavor::LuaTeX), useBabel());
|
2003-07-29 12:20:04 +00:00
|
|
|
|
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);
|
2011-12-03 22:15:11 +00:00
|
|
|
|
|
|
|
if (mustProvide("refstyle"))
|
|
|
|
macros << lyxref_def << '\n';
|
|
|
|
|
2007-05-08 17:46:03 +00:00
|
|
|
// change tracking
|
2009-01-12 08:01:28 +00:00
|
|
|
if (mustProvide("ct-xcolor-ulem")) {
|
2016-09-25 10:38:53 +00:00
|
|
|
streamsize const prec = macros.os().precision(2);
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2020-08-03 12:10:46 +00:00
|
|
|
RGBColor cadd = rgbFromHexName(lcolor.getX11HexName(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
|
|
|
|
2020-08-03 12:10:46 +00:00
|
|
|
RGBColor cdel = rgbFromHexName(lcolor.getX11HexName(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";
|
|
|
|
|
2016-09-25 10:38:53 +00:00
|
|
|
macros.os().precision(prec);
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2019-12-28 12:41:19 +00:00
|
|
|
macros << changetracking_xcolor_ulem_base_def;
|
|
|
|
|
2019-12-24 17:12:22 +00:00
|
|
|
if (isRequired("changebar")) {
|
|
|
|
if (isRequired("hyperref"))
|
|
|
|
macros << changetracking_xcolor_ulem_hyperref_cb_def;
|
|
|
|
else
|
|
|
|
macros << changetracking_xcolor_ulem_cb_def;
|
|
|
|
} else {
|
|
|
|
if (isRequired("hyperref"))
|
|
|
|
macros << changetracking_xcolor_ulem_hyperref_def;
|
|
|
|
else
|
|
|
|
macros << changetracking_xcolor_ulem_def;
|
|
|
|
}
|
2007-05-13 15:17:57 +00:00
|
|
|
}
|
2007-11-02 23:42:27 +00:00
|
|
|
|
2019-12-28 12:43:17 +00:00
|
|
|
if (mustProvide("ct-tikz-object-sout")) {
|
|
|
|
if (!mustProvide("ct-xcolor-ulem")) {
|
|
|
|
streamsize const prec = macros.os().precision(2);
|
|
|
|
|
2020-08-03 12:10:46 +00:00
|
|
|
RGBColor cadd = rgbFromHexName(lcolor.getX11HexName(Color_addedtext));
|
2019-12-28 12:43:17 +00:00
|
|
|
macros << "\\providecolor{lyxadded}{rgb}{"
|
|
|
|
<< cadd.r / 255.0 << ',' << cadd.g / 255.0 << ',' << cadd.b / 255.0 << "}\n";
|
|
|
|
|
2020-08-03 12:10:46 +00:00
|
|
|
RGBColor cdel = rgbFromHexName(lcolor.getX11HexName(Color_deletedtext));
|
2019-12-28 12:43:17 +00:00
|
|
|
macros << "\\providecolor{lyxdeleted}{rgb}{"
|
|
|
|
<< cdel.r / 255.0 << ',' << cdel.g / 255.0 << ',' << cdel.b / 255.0 << "}\n";
|
|
|
|
|
|
|
|
macros.os().precision(prec);
|
|
|
|
}
|
|
|
|
|
2019-12-26 06:15:37 +00:00
|
|
|
macros << changetracking_tikz_object_sout_def;
|
2019-12-28 12:43:17 +00:00
|
|
|
|
|
|
|
if (isRequired("changebar")) {
|
|
|
|
if (isRequired("hyperref"))
|
|
|
|
macros << changetracking_xcolor_ulem_hyperref_cb_object_def;
|
|
|
|
else
|
|
|
|
macros << changetracking_xcolor_ulem_cb_object_def;
|
|
|
|
} else {
|
|
|
|
if (isRequired("hyperref"))
|
|
|
|
macros << changetracking_xcolor_ulem_hyperref_object_def;
|
|
|
|
else
|
|
|
|
macros << changetracking_xcolor_ulem_object_def;
|
|
|
|
}
|
|
|
|
}
|
2016-10-17 01:25:35 +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;
|
|
|
|
|
2012-09-22 21:14:34 +00:00
|
|
|
if (mustProvide("rtloutputdblcol"))
|
|
|
|
macros << rtloutputdblcol_def;
|
|
|
|
|
2017-06-10 16:43:23 +00:00
|
|
|
if (mustProvide("lyxmintcaption"))
|
|
|
|
macros << lyxmintcaption_def;
|
|
|
|
|
2016-09-25 10:38:53 +00:00
|
|
|
return macros.release();
|
2002-05-10 12:58:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-25 10:37:40 +00:00
|
|
|
docstring const LaTeXFeatures::getBabelPresettings() const
|
2010-11-14 09:54:24 +00:00
|
|
|
{
|
2016-09-25 10:37:40 +00:00
|
|
|
odocstringstream tmp;
|
2010-11-14 09:54:24 +00:00
|
|
|
|
2020-08-23 11:48:45 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
2016-09-25 10:37:40 +00:00
|
|
|
if (!lang->babel_presettings().empty())
|
|
|
|
tmp << lang->babel_presettings() << '\n';
|
2010-11-14 09:54:24 +00:00
|
|
|
if (!params_.language->babel_presettings().empty())
|
|
|
|
tmp << params_.language->babel_presettings() << '\n';
|
|
|
|
|
2012-07-18 10:41:53 +00:00
|
|
|
if (!contains(tmp.str(), '@'))
|
|
|
|
return tmp.str();
|
|
|
|
|
|
|
|
return "\\makeatletter\n" + tmp.str() + "\\makeatother\n";
|
2010-11-14 09:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-25 10:37:40 +00:00
|
|
|
docstring const LaTeXFeatures::getBabelPostsettings() const
|
2002-05-10 12:58:07 +00:00
|
|
|
{
|
2016-09-25 10:37:40 +00:00
|
|
|
odocstringstream tmp;
|
2002-05-10 12:58:07 +00:00
|
|
|
|
2020-08-23 11:48:45 +00:00
|
|
|
for (auto const & lang : UsedLanguages_)
|
2016-09-25 10:37:40 +00:00
|
|
|
if (!lang->babel_postsettings().empty())
|
|
|
|
tmp << lang->babel_postsettings() << '\n';
|
2010-11-13 17:25:03 +00:00
|
|
|
if (!params_.language->babel_postsettings().empty())
|
|
|
|
tmp << params_.language->babel_postsettings() << '\n';
|
2001-01-20 14:16:01 +00:00
|
|
|
|
2012-07-18 10:41:53 +00:00
|
|
|
if (!contains(tmp.str(), '@'))
|
|
|
|
return tmp.str();
|
|
|
|
|
|
|
|
return "\\makeatletter\n" + tmp.str() + "\\makeatother\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 18:42:10 +00:00
|
|
|
string const LaTeXFeatures::loadAMSPackages() const
|
|
|
|
{
|
|
|
|
ostringstream tmp;
|
|
|
|
|
2011-10-18 19:32:02 +00:00
|
|
|
if (mustProvide("amsmath")
|
2012-01-03 20:51:07 +00:00
|
|
|
&& params_.use_package("amsmath") != BufferParams::package_off) {
|
2010-12-08 18:42:10 +00:00
|
|
|
tmp << "\\usepackage{amsmath}\n";
|
|
|
|
} else {
|
|
|
|
// amsbsy and amstext are already provided by amsmath
|
|
|
|
if (mustProvide("amsbsy"))
|
|
|
|
tmp << "\\usepackage{amsbsy}\n";
|
|
|
|
if (mustProvide("amstext"))
|
|
|
|
tmp << "\\usepackage{amstext}\n";
|
|
|
|
}
|
2011-10-18 19:32:02 +00:00
|
|
|
|
2015-03-22 10:14:08 +00:00
|
|
|
if (mustProvide("amsthm"))
|
|
|
|
tmp << "\\usepackage{amsthm}\n";
|
|
|
|
|
2010-12-08 18:42:10 +00:00
|
|
|
if (mustProvide("amssymb")
|
2012-05-06 18:48:04 +00:00
|
|
|
&& params_.use_package("amssymb") != BufferParams::package_off)
|
2010-12-08 18:42:10 +00:00
|
|
|
tmp << "\\usepackage{amssymb}\n";
|
|
|
|
|
|
|
|
return tmp.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-02-17 20:25:56 +00:00
|
|
|
list<docstring>::const_iterator cit = usedLayouts_.begin();
|
|
|
|
list<docstring>::const_iterator end = usedLayouts_.end();
|
|
|
|
for (; cit != end; ++cit)
|
2017-02-18 09:40:42 +00:00
|
|
|
// For InPreamble layouts, we output the preamble stuff earlier
|
|
|
|
// (before the layouts). See Paragraph::Private::validate.
|
|
|
|
if (!tclass[*cit].inpreamble)
|
|
|
|
tcpreamble << tclass[*cit].preamble();
|
2009-02-17 20:25:56 +00:00
|
|
|
|
2009-06-03 23:44:31 +00:00
|
|
|
cit = usedInsetLayouts_.begin();
|
|
|
|
end = usedInsetLayouts_.end();
|
|
|
|
TextClass::InsetLayouts const & ils = tclass.insetLayouts();
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
TextClass::InsetLayouts::const_iterator it = ils.find(*cit);
|
|
|
|
if (it == ils.end())
|
|
|
|
continue;
|
|
|
|
tcpreamble << it->second.preamble();
|
|
|
|
}
|
|
|
|
|
2009-02-17 20:25:56 +00:00
|
|
|
return tcpreamble.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-03 22:15:11 +00:00
|
|
|
docstring const LaTeXFeatures::getTClassHTMLPreamble() const
|
2009-06-05 20:00:55 +00:00
|
|
|
{
|
2009-06-05 17:39:00 +00:00
|
|
|
DocumentClass const & tclass = params_.documentClass();
|
|
|
|
odocstringstream tcpreamble;
|
|
|
|
|
|
|
|
tcpreamble << tclass.htmlpreamble();
|
|
|
|
|
|
|
|
list<docstring>::const_iterator cit = usedLayouts_.begin();
|
2009-06-05 19:42:56 +00:00
|
|
|
list<docstring>::const_iterator end = usedLayouts_.end();
|
|
|
|
for (; cit != end; ++cit)
|
|
|
|
tcpreamble << tclass[*cit].htmlpreamble();
|
|
|
|
|
|
|
|
cit = usedInsetLayouts_.begin();
|
|
|
|
end = usedInsetLayouts_.end();
|
|
|
|
TextClass::InsetLayouts const & ils = tclass.insetLayouts();
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
TextClass::InsetLayouts::const_iterator it = ils.find(*cit);
|
|
|
|
if (it == ils.end())
|
|
|
|
continue;
|
|
|
|
tcpreamble << it->second.htmlpreamble();
|
|
|
|
}
|
|
|
|
|
|
|
|
return tcpreamble.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-06 22:38:46 +00:00
|
|
|
docstring const LaTeXFeatures::getTClassHTMLStyles() const
|
|
|
|
{
|
2009-06-05 19:42:56 +00:00
|
|
|
DocumentClass const & tclass = params_.documentClass();
|
|
|
|
odocstringstream tcpreamble;
|
|
|
|
|
2013-03-27 16:49:03 +00:00
|
|
|
if (mustProvide("noun"))
|
|
|
|
tcpreamble << lyxnoun_style;
|
|
|
|
// this isn't exact, but it won't hurt that much if it
|
|
|
|
// wasn't for this.
|
|
|
|
if (mustProvide("ulem"))
|
|
|
|
tcpreamble << lyxstrikeout_style;
|
|
|
|
|
2011-12-06 22:38:46 +00:00
|
|
|
tcpreamble << tclass.htmlstyles();
|
|
|
|
|
2009-06-05 19:42:56 +00:00
|
|
|
list<docstring>::const_iterator cit = usedLayouts_.begin();
|
2009-06-05 17:39:00 +00:00
|
|
|
list<docstring>::const_iterator end = usedLayouts_.end();
|
|
|
|
for (; cit != end; ++cit)
|
|
|
|
tcpreamble << tclass[*cit].htmlstyle();
|
|
|
|
|
|
|
|
cit = usedInsetLayouts_.begin();
|
|
|
|
end = usedInsetLayouts_.end();
|
|
|
|
TextClass::InsetLayouts const & ils = tclass.insetLayouts();
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
TextClass::InsetLayouts::const_iterator it = ils.find(*cit);
|
|
|
|
if (it == ils.end())
|
|
|
|
continue;
|
|
|
|
tcpreamble << it->second.htmlstyle();
|
|
|
|
}
|
|
|
|
|
|
|
|
return tcpreamble.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
namespace {
|
2012-10-27 13:45:27 +00:00
|
|
|
|
2011-10-08 22:13:38 +00:00
|
|
|
docstring const getFloatI18nPreamble(docstring const & type,
|
|
|
|
docstring const & name, Language const * lang,
|
2012-01-14 14:27:55 +00:00
|
|
|
Encoding const & enc, bool const polyglossia)
|
2009-06-09 18:16:43 +00:00
|
|
|
{
|
2012-01-14 01:21:00 +00:00
|
|
|
// Check whether name can be encoded in the buffer encoding
|
|
|
|
bool encodable = true;
|
2020-10-09 06:04:20 +00:00
|
|
|
for (char_type c : name) {
|
|
|
|
if (!enc.encodable(c)) {
|
2012-01-14 14:27:55 +00:00
|
|
|
encodable = false;
|
|
|
|
break;
|
2012-01-14 01:21:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-08 22:13:38 +00:00
|
|
|
docstring const language = polyglossia ? from_ascii(lang->polyglossia())
|
|
|
|
: from_ascii(lang->babel());
|
2011-10-09 14:45:51 +00:00
|
|
|
docstring const langenc = from_ascii(lang->encoding()->iconvName());
|
2011-10-08 22:13:38 +00:00
|
|
|
docstring const texenc = from_ascii(lang->encoding()->latexName());
|
2011-10-09 14:45:51 +00:00
|
|
|
docstring const bufenc = from_ascii(enc.iconvName());
|
|
|
|
docstring const s1 = docstring(1, 0xF0000);
|
|
|
|
docstring const s2 = docstring(1, 0xF0001);
|
2012-01-14 01:21:00 +00:00
|
|
|
docstring const translated = encodable ? name
|
2011-10-08 22:13:38 +00:00
|
|
|
: from_ascii("\\inputencoding{") + texenc + from_ascii("}")
|
2011-12-17 18:22:24 +00:00
|
|
|
+ s1 + langenc + s2 + name + s1 + bufenc + s2;
|
2011-10-08 22:13:38 +00:00
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
odocstringstream os;
|
2011-10-08 22:13:38 +00:00
|
|
|
os << "\\addto\\captions" << language
|
|
|
|
<< "{\\renewcommand{\\" << type << "name}{" << translated << "}}\n";
|
2009-06-09 18:16:43 +00:00
|
|
|
return os.str();
|
|
|
|
}
|
2012-04-10 18:21:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
docstring const i18npreamble(docstring const & templ, Language const * lang,
|
2015-01-11 18:17:51 +00:00
|
|
|
Encoding const & enc, bool const polyglossia,
|
|
|
|
bool const need_fixedwidth)
|
2012-04-10 18:21:01 +00:00
|
|
|
{
|
|
|
|
if (templ.empty())
|
|
|
|
return templ;
|
|
|
|
|
|
|
|
string preamble = polyglossia ?
|
|
|
|
subst(to_utf8(templ), "$$lang", lang->polyglossia()) :
|
|
|
|
subst(to_utf8(templ), "$$lang", lang->babel());
|
|
|
|
|
|
|
|
string const langenc = lang->encoding()->iconvName();
|
|
|
|
string const texenc = lang->encoding()->latexName();
|
|
|
|
string const bufenc = enc.iconvName();
|
2015-01-11 18:17:51 +00:00
|
|
|
Encoding const * testenc(&enc);
|
|
|
|
bool lang_fallback = false;
|
|
|
|
bool ascii_fallback = false;
|
|
|
|
if (need_fixedwidth && !enc.hasFixedWidth()) {
|
|
|
|
if (lang->encoding()->hasFixedWidth()) {
|
|
|
|
testenc = lang->encoding();
|
|
|
|
lang_fallback = true;
|
|
|
|
} else {
|
|
|
|
// We need a fixed width encoding, but both the buffer
|
|
|
|
// encoding and the language encoding are variable
|
|
|
|
// width. As a last fallback, try to convert to pure
|
|
|
|
// ASCII using the LaTeX commands defined in unicodesymbols.
|
|
|
|
testenc = encodings.fromLyXName("ascii");
|
|
|
|
if (!testenc)
|
|
|
|
return docstring();
|
|
|
|
ascii_fallback = true;
|
|
|
|
}
|
|
|
|
}
|
2012-04-10 18:21:01 +00:00
|
|
|
// First and second character of plane 15 (Private Use Area)
|
|
|
|
string const s1 = "\xf3\xb0\x80\x80"; // U+F0000
|
|
|
|
string const s2 = "\xf3\xb0\x80\x81"; // U+F0001
|
|
|
|
// FIXME UNICODE
|
|
|
|
// lyx::regex is not unicode-safe.
|
|
|
|
// Should use QRegExp or (boost::u32regex, but that requires ICU)
|
|
|
|
static regex const reg("_\\(([^\\)]+)\\)");
|
|
|
|
smatch sub;
|
|
|
|
while (regex_search(preamble, sub, reg)) {
|
|
|
|
string const key = sub.str(1);
|
|
|
|
docstring const name = lang->translateLayout(key);
|
|
|
|
// Check whether name can be encoded in the buffer encoding
|
|
|
|
bool encodable = true;
|
2015-01-11 18:17:51 +00:00
|
|
|
for (size_t i = 0; i < name.size() && encodable; ++i)
|
|
|
|
if (!testenc->encodable(name[i]))
|
2012-04-10 18:21:01 +00:00
|
|
|
encodable = false;
|
2015-01-11 18:17:51 +00:00
|
|
|
string translated;
|
|
|
|
if (encodable && !lang_fallback)
|
|
|
|
translated = to_utf8(name);
|
|
|
|
else if (ascii_fallback)
|
|
|
|
translated = to_ascii(testenc->latexString(name).first);
|
|
|
|
else
|
|
|
|
translated = "\\inputencoding{" + texenc + "}"
|
|
|
|
+ s1 + langenc + s2 + to_utf8(name)
|
|
|
|
+ s1 + bufenc + s2;
|
2012-04-10 18:21:01 +00:00
|
|
|
preamble = subst(preamble, sub.str(), translated);
|
|
|
|
}
|
|
|
|
return from_utf8(preamble);
|
|
|
|
}
|
|
|
|
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace
|
2009-06-09 18:16:43 +00:00
|
|
|
|
|
|
|
|
2017-06-06 22:55:23 +00:00
|
|
|
docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel,
|
|
|
|
bool use_polyglossia, bool use_minted) const
|
2009-02-17 20:25:56 +00:00
|
|
|
{
|
|
|
|
DocumentClass const & tclass = params_.documentClass();
|
|
|
|
// collect preamble snippets in a set to prevent multiple identical
|
|
|
|
// commands (would happen if e.g. both theorem and theorem* are used)
|
|
|
|
set<docstring> snippets;
|
2009-02-04 20:06:50 +00:00
|
|
|
typedef LanguageList::const_iterator lang_it;
|
|
|
|
lang_it const lbeg = UsedLanguages_.begin();
|
|
|
|
lang_it const lend = UsedLanguages_.end();
|
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) {
|
2009-02-17 20:25:56 +00:00
|
|
|
// language dependent commands (once per document)
|
2012-04-10 18:21:01 +00:00
|
|
|
snippets.insert(i18npreamble(tclass[*cit].langpreamble(),
|
|
|
|
buffer().language(),
|
2011-10-09 14:45:51 +00:00
|
|
|
buffer().params().encoding(),
|
2015-01-11 18:17:51 +00:00
|
|
|
use_polyglossia, false));
|
2009-02-17 20:25:56 +00:00
|
|
|
// commands for language changing (for multilanguage documents)
|
2010-12-08 12:10:22 +00:00
|
|
|
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
|
2012-04-10 18:21:01 +00:00
|
|
|
snippets.insert(i18npreamble(
|
|
|
|
tclass[*cit].babelpreamble(),
|
2011-10-09 14:45:51 +00:00
|
|
|
buffer().language(),
|
|
|
|
buffer().params().encoding(),
|
2015-01-11 18:17:51 +00:00
|
|
|
use_polyglossia, false));
|
2009-02-17 20:25:56 +00:00
|
|
|
for (lang_it lit = lbeg; lit != lend; ++lit)
|
2012-04-10 18:21:01 +00:00
|
|
|
snippets.insert(i18npreamble(
|
|
|
|
tclass[*cit].babelpreamble(),
|
2011-10-09 14:45:51 +00:00
|
|
|
*lit,
|
|
|
|
buffer().params().encoding(),
|
2015-01-11 18:17:51 +00:00
|
|
|
use_polyglossia, false));
|
2009-02-17 20:25:56 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2010-12-08 12:10:22 +00:00
|
|
|
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
|
2009-06-09 18:16:43 +00:00
|
|
|
FloatList const & floats = params_.documentClass().floats();
|
|
|
|
UsedFloats::const_iterator fit = usedFloats_.begin();
|
|
|
|
UsedFloats::const_iterator fend = usedFloats_.end();
|
|
|
|
for (; fit != fend; ++fit) {
|
|
|
|
Floating const & fl = floats.getType(fit->first);
|
2011-12-03 22:15:11 +00:00
|
|
|
// we assume builtin floats are translated
|
2011-03-20 10:50:43 +00:00
|
|
|
if (fl.isPredefined())
|
|
|
|
continue;
|
2010-03-04 13:42:05 +00:00
|
|
|
docstring const type = from_ascii(fl.floattype());
|
2009-06-09 18:16:43 +00:00
|
|
|
docstring const flname = from_utf8(fl.name());
|
2011-03-23 19:17:15 +00:00
|
|
|
docstring name = buffer().language()->translateLayout(fl.name());
|
2011-03-20 10:50:43 +00:00
|
|
|
// only request translation if we have a real translation
|
|
|
|
// (that differs from the source)
|
2011-10-08 22:13:38 +00:00
|
|
|
if (flname != name)
|
2010-12-08 12:10:22 +00:00
|
|
|
snippets.insert(getFloatI18nPreamble(
|
2011-10-09 14:45:51 +00:00
|
|
|
type, name, buffer().language(),
|
|
|
|
buffer().params().encoding(),
|
2012-01-14 14:27:55 +00:00
|
|
|
use_polyglossia));
|
2009-06-09 18:16:43 +00:00
|
|
|
for (lang_it lit = lbeg; lit != lend; ++lit) {
|
2011-03-20 11:39:02 +00:00
|
|
|
string const code = (*lit)->code();
|
2011-04-07 19:17:30 +00:00
|
|
|
name = (*lit)->translateLayout(fl.name());
|
2011-03-20 11:39:02 +00:00
|
|
|
// we assume we have a suitable translation if
|
|
|
|
// either the language is English (we need to
|
|
|
|
// translate into English if English is a secondary
|
|
|
|
// language) or if translateIfPossible returns
|
|
|
|
// something different to the English source.
|
|
|
|
bool const have_translation =
|
|
|
|
(flname != name || contains(code, "en"));
|
2011-10-08 22:13:38 +00:00
|
|
|
if (have_translation)
|
2010-12-08 12:10:22 +00:00
|
|
|
snippets.insert(getFloatI18nPreamble(
|
2011-10-09 14:45:51 +00:00
|
|
|
type, name, *lit,
|
|
|
|
buffer().params().encoding(),
|
2012-01-14 14:27:55 +00:00
|
|
|
use_polyglossia));
|
2009-06-09 18:16:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2012-04-10 18:21:01 +00:00
|
|
|
cit = usedInsetLayouts_.begin();
|
|
|
|
end = usedInsetLayouts_.end();
|
|
|
|
TextClass::InsetLayouts const & ils = tclass.insetLayouts();
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
TextClass::InsetLayouts::const_iterator it = ils.find(*cit);
|
|
|
|
if (it == ils.end())
|
|
|
|
continue;
|
2015-01-11 18:17:51 +00:00
|
|
|
// The listings package does not work with variable width
|
|
|
|
// encodings, only with fixed width encodings. Therefore we
|
|
|
|
// need to force a fixed width encoding for
|
|
|
|
// \lstlistlistingname and \lstlistingname (bug 9382).
|
2019-04-18 13:20:06 +00:00
|
|
|
// This needs to be consistent with InsetListings::latex()
|
|
|
|
// rsp. InsetListings::forcedEncoding().
|
2017-06-06 22:55:23 +00:00
|
|
|
bool const need_fixedwidth = !use_minted &&
|
|
|
|
!runparams_.isFullUnicode() &&
|
2019-04-18 13:20:06 +00:00
|
|
|
buffer().params().encoding().package() != Encoding::japanese &&
|
2017-06-06 22:55:23 +00:00
|
|
|
it->second.fixedwidthpreambleencoding();
|
2012-04-10 18:21:01 +00:00
|
|
|
// language dependent commands (once per document)
|
|
|
|
snippets.insert(i18npreamble(it->second.langpreamble(),
|
|
|
|
buffer().language(),
|
|
|
|
buffer().params().encoding(),
|
2015-01-11 18:17:51 +00:00
|
|
|
use_polyglossia, need_fixedwidth));
|
2012-04-10 18:21:01 +00:00
|
|
|
// commands for language changing (for multilanguage documents)
|
|
|
|
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
|
|
|
|
snippets.insert(i18npreamble(
|
|
|
|
it->second.babelpreamble(),
|
|
|
|
buffer().language(),
|
|
|
|
buffer().params().encoding(),
|
2015-01-11 18:17:51 +00:00
|
|
|
use_polyglossia, need_fixedwidth));
|
2012-04-10 18:21:01 +00:00
|
|
|
for (lang_it lit = lbeg; lit != lend; ++lit)
|
|
|
|
snippets.insert(i18npreamble(
|
|
|
|
it->second.babelpreamble(),
|
|
|
|
*lit,
|
|
|
|
buffer().params().encoding(),
|
2015-01-11 18:17:51 +00:00
|
|
|
use_polyglossia, need_fixedwidth));
|
2012-04-10 18:21:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-17 20:25:56 +00:00
|
|
|
odocstringstream tcpreamble;
|
|
|
|
set<docstring>::const_iterator const send = snippets.end();
|
|
|
|
set<docstring>::const_iterator it = snippets.begin();
|
|
|
|
for (; it != send; ++it)
|
|
|
|
tcpreamble << *it;
|
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
|
2010-04-21 01:19:31 +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()
|
2016-09-25 10:38:53 +00:00
|
|
|
<< "\n***** Macros:" << to_utf8(getMacros().str)
|
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
|
|
|
|
2016-09-25 10:38:53 +00:00
|
|
|
void LaTeXFeatures::getFloatDefinitions(otexstream & 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}
|
2009-06-09 18:16:43 +00:00
|
|
|
// \providecommand{\algorithmname}{Algorithm}
|
|
|
|
// \floatname{algorithm}{\protect\algorithmname}
|
2020-12-03 19:51:25 +00:00
|
|
|
for (auto const & cit : usedFloats_) {
|
|
|
|
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.
|
2011-02-02 22:57:00 +00:00
|
|
|
if (fl.isPredefined())
|
2010-03-04 13:42:05 +00:00
|
|
|
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"
|
2010-03-04 13:42:05 +00:00
|
|
|
if (fl.floattype() == "tabular" || fl.floattype() == "figure") {
|
2001-05-08 17:08:44 +00:00
|
|
|
// Output code to modify "table" or "figure"
|
|
|
|
// but only if builtin == false
|
|
|
|
// and that have to be true at this point in the
|
|
|
|
// function.
|
2010-03-04 13:42:05 +00:00
|
|
|
docstring const type = from_ascii(fl.floattype());
|
2009-06-09 18:16:43 +00:00
|
|
|
docstring const placement = from_ascii(fl.placement());
|
|
|
|
docstring const style = from_ascii(fl.style());
|
2001-05-08 17:08:44 +00:00
|
|
|
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
|
|
|
|
2010-03-04 13:42:05 +00:00
|
|
|
docstring const type = from_ascii(fl.floattype());
|
2009-06-09 18:16:43 +00:00
|
|
|
docstring const placement = from_ascii(fl.placement());
|
|
|
|
docstring const ext = from_ascii(fl.ext());
|
|
|
|
docstring const within = from_ascii(fl.within());
|
|
|
|
docstring const style = from_ascii(fl.style());
|
2011-04-07 19:17:30 +00:00
|
|
|
docstring const name =
|
|
|
|
buffer().language()->translateLayout(fl.name());
|
2001-05-08 17:08:44 +00:00
|
|
|
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'
|
2009-06-09 18:16:43 +00:00
|
|
|
<< "\\providecommand{\\" << type << "name}{"
|
|
|
|
<< name << "}\n"
|
|
|
|
<< "\\floatname{" << type << "}{\\protect\\"
|
|
|
|
<< 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)
|
|
|
|
}
|
2020-12-03 19:51:25 +00:00
|
|
|
if (cit.second)
|
2013-10-13 09:45:59 +00:00
|
|
|
// The subfig package is loaded later
|
|
|
|
os << "\n\\AtBeginDocument{\\newsubfloat{" << from_ascii(fl.floattype()) << "}}\n";
|
2001-05-08 17:08:44 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2011-10-18 19:32:02 +00:00
|
|
|
void LaTeXFeatures::resolveAlternatives()
|
|
|
|
{
|
|
|
|
for (Features::iterator it = features_.begin(); it != features_.end();) {
|
|
|
|
if (contains(*it, '|')) {
|
|
|
|
vector<string> const alternatives = getVectorFromString(*it, "|");
|
|
|
|
vector<string>::const_iterator const end = alternatives.end();
|
|
|
|
vector<string>::const_iterator ita = alternatives.begin();
|
2015-05-16 10:29:54 +00:00
|
|
|
// Is any alternative already required? => use that
|
2011-10-18 19:32:02 +00:00
|
|
|
for (; ita != end; ++ita) {
|
|
|
|
if (isRequired(*ita))
|
|
|
|
break;
|
|
|
|
}
|
2015-05-16 10:29:54 +00:00
|
|
|
// Is any alternative available? => use the first one
|
|
|
|
// (bug 9498)
|
|
|
|
if (ita == end) {
|
|
|
|
for (ita = alternatives.begin(); ita != end; ++ita) {
|
|
|
|
if (isAvailable(*ita)) {
|
|
|
|
require(*ita);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// This will not work, but not requiring something
|
|
|
|
// would be more confusing
|
2011-10-18 19:32:02 +00:00
|
|
|
if (ita == end)
|
|
|
|
require(alternatives.front());
|
|
|
|
features_.erase(it);
|
|
|
|
it = features_.begin();
|
|
|
|
} else
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-10 16:32:44 +00:00
|
|
|
void LaTeXFeatures::expandMultiples()
|
|
|
|
{
|
|
|
|
for (Features::iterator it = features_.begin(); it != features_.end();) {
|
|
|
|
if (contains(*it, ',')) {
|
|
|
|
// Do nothing if any multiple is already required
|
2020-12-03 19:51:25 +00:00
|
|
|
for (string const & pkg : getVectorFromString(*it, ",")) {
|
|
|
|
if (!isRequired(pkg))
|
|
|
|
require(pkg);
|
2016-09-10 16:32:44 +00:00
|
|
|
}
|
|
|
|
features_.erase(it);
|
|
|
|
it = features_.begin();
|
|
|
|
} else
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|