3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #ifndef LYX_PREAMBLE_H
15 #define LYX_PREAMBLE_H
30 class TeX2LyXDocClass;
38 std::string inputencoding() const { return h_inputencoding; }
40 void setInputencoding(std::string const & e) { h_inputencoding = e; }
42 std::string notefontcolor() const { return h_notefontcolor; }
44 bool refstyle() const { return h_use_refstyle; }
46 bool fontCJKSet() const { return h_font_cjk_set; }
48 std::string fontCJK() const { return h_font_cjk; }
50 void fontCJK(std::string const & f) { h_font_cjk_set = true; h_font_cjk = f; }
52 bool minted() const { return h_use_minted; }
53 /// The document language
54 std::string docLanguage() const { return h_language; }
55 /// The language of text which is not explicitly marked
56 std::string defaultLanguage() const { return default_language; }
57 /// The quotation marks style
58 std::string quotesStyle() const { return h_quotes_style; }
60 bool usePolyglossia() const;
62 std::string use_indices() const { return h_use_indices; }
64 std::string polyglossia2lyx(std::string const & language);
66 bool indentParagraphs() const;
68 bool isPackageUsed(std::string const & package) const;
70 std::vector<std::string>
71 getPackageOptions(std::string const & package) const;
72 /// Tell that \p package will be loaded automatically by LyX.
73 /// This has only an effect if \p package is prepared for
74 /// autoloading in parse().
75 void registerAutomaticallyLoadedPackage(std::string const & package);
77 void addModule(std::string const & module);
79 void suppressDate(bool suppress);
81 std::string citeEngine() const { return h_cite_engine; }
83 void citeEngine(std::string const & e) { h_cite_engine = e; }
85 bool titleLayoutFound() const { return title_layout_found; }
87 void titleLayoutFound(bool found) { title_layout_found = found; }
88 /// Register an author named \p name in the author list
89 void registerAuthor(std::string const & name);
90 /// Get author named \p name (must be registered first)
91 Author const & getAuthor(std::string const & name) const;
92 /// Get number of arguments of special table column type \c or -1
93 /// if no column type \p c exists
94 int getSpecialTableColumnArguments(char c) const;
96 /// Parses the LaTeX preamble into internal data
97 void parse(Parser & p, std::string const & forceclass,
98 TeX2LyXDocClass & tc);
99 /// Parse the encoding from a preamble. *this is unusable afterwards.
100 std::string parseEncoding(Parser & p, std::string const & forceclass);
101 /// Writes the LyX file header from internal data
102 bool writeLyXHeader(std::ostream & os, bool subdoc,
103 std::string const & outfiledir);
105 /// known polyglossia language names (including variants)
106 static const char * const polyglossia_languages[];
107 /// the same as polyglossia_languages with .lyx names
108 static const char * const coded_polyglossia_languages[];
110 std::vector<std::string> biblatex_bibliographies;
114 void parse(Parser & p, std::string const & forceclass,
115 bool detectEncoding, TeX2LyXDocClass & tc);
117 std::map<std::string, std::vector<std::string> > used_packages;
118 /// Packages that will be loaded automatically by LyX
119 std::set<std::string> auto_packages;
121 std::vector<std::string> used_modules;
123 /// needed to handle encodings with babel
125 /// the main non-CJK language
126 std::string default_language;
127 /// Was babel called explicitly?
130 /// was at least one title layout found?
131 bool title_layout_found;
133 /// used for the handling of \newindex
136 std::ostringstream h_preamble;
137 std::string h_backgroundcolor;
138 std::string h_multibib;
139 std::string h_biblio_style;
140 std::string h_biblio_options;
141 std::string h_biblatex_bibstyle;
142 std::string h_biblatex_citestyle;
143 std::string h_bibtex_command;
144 std::string h_boxbgcolor;
145 std::string h_cite_engine;
146 std::string h_cite_engine_type;
148 std::string h_defskip;
149 bool h_dynamic_quotes;
150 std::string h_float_placement;
151 std::string h_fontcolor;
152 std::string h_fontencoding;
153 std::string h_font_math[2];
154 std::string h_font_roman[2];
155 std::string h_font_sans[2];
156 std::string h_font_typewriter[2];
157 std::string h_font_default_family;
158 bool h_use_non_tex_fonts;
159 std::string h_font_sc;
160 std::string h_font_osf;
161 std::string h_font_sf_scale[2];
162 std::string h_font_tt_scale[2];
164 std::string h_font_cjk;
165 std::string h_use_microtype;
166 std::string h_is_mathindent;
167 std::string h_math_numbering_side;
168 std::string h_mathindentation;
169 std::string h_graphics;
170 std::string h_default_output_format;
171 std::string h_html_be_strict;
172 std::string h_html_css_as_file;
173 std::string h_html_math_output;
174 std::string h_index[99];
175 std::string h_index_command;
176 std::string h_inputencoding;
177 std::string h_justification;
178 std::string h_language;
179 std::string h_language_package;
180 std::string h_listings_params;
181 std::string h_maintain_unincluded_children;
182 std::string h_margins;
183 std::string h_notefontcolor;
184 std::string h_options;
185 std::string h_output_changes;
186 std::string h_output_sync;
187 std::string h_output_sync_macro;
188 std::string h_papercolumns;
189 std::string h_paperfontsize;
190 std::string h_paperorientation;
191 std::string h_paperpagestyle;
192 std::string h_papersides;
193 std::string h_papersize;
194 std::string h_paragraph_indentation;
195 /// necessary to set the separation when \setlength is parsed
196 std::string h_paragraph_separation;
197 std::string h_pdf_title;
198 std::string h_pdf_author;
199 std::string h_pdf_subject;
200 std::string h_pdf_keywords;
201 std::string h_pdf_bookmarks;
202 std::string h_pdf_bookmarksnumbered;
203 std::string h_pdf_bookmarksopen;
204 std::string h_pdf_bookmarksopenlevel;
205 std::string h_pdf_breaklinks;
206 std::string h_pdf_pdfborder;
207 std::string h_pdf_colorlinks;
208 std::string h_pdf_backref;
209 std::string h_pdf_pdfusetitle;
210 std::string h_pdf_pagemode;
211 std::string h_pdf_quoted_options;
212 std::string h_quotes_style;
213 std::string h_secnumdepth;
214 std::string h_shortcut[99];
215 std::string h_spacing;
216 std::string h_suppress_date;
217 std::string h_save_transient_properties;
218 std::string h_textclass;
219 std::string h_tocdepth;
220 std::string h_tracking_changes;
221 std::string h_use_bibtopic;
222 std::string h_use_dash_ligatures;
223 std::string h_use_indices;
224 std::string h_use_geometry;
225 std::map<std::string, std::string> h_use_packages;
226 std::string h_use_default_options;
227 std::string h_use_hyperref;
228 std::vector<std::string> h_includeonlys;
233 * Add package \p name with options \p options to used_packages.
234 * Remove options from \p options that we don't want to output.
236 void add_package(std::string const & name,
237 std::vector<std::string> & options);
239 void handle_hyperref(std::vector<std::string> & options);
241 void handle_geometry(std::vector<std::string> & options);
243 void handle_package(Parser &p, std::string const & name,
244 std::string const & opts, bool in_lyx_preamble,
245 bool detectEncoding);
247 void handle_if(Parser & p, bool in_lyx_preamble);
251 /// special table column types
252 std::map<char, int> special_columns_;
254 std::map<std::string, std::string> extra_package_options_;
258 extern Preamble preamble;