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; }
51 /// The document language
52 std::string docLanguage() const { return h_language; }
53 /// The language of text which is not explicitly marked
54 std::string defaultLanguage() const { return default_language; }
56 bool usePolyglossia() const;
58 std::string use_indices() const { return h_use_indices; }
60 std::string polyglossia2lyx(std::string const & language);
62 bool indentParagraphs() const;
64 bool isPackageUsed(std::string const & package) const;
66 std::vector<std::string>
67 getPackageOptions(std::string const & package) const;
68 /// Tell that \p package will be loaded automatically by LyX.
69 /// This has only an effect if \p package is prepared for
70 /// autoloading in parse().
71 void registerAutomaticallyLoadedPackage(std::string const & package);
73 void addModule(std::string const & module);
75 void suppressDate(bool suppress);
77 std::string citeEngine() const { return h_cite_engine; }
79 void citeEngine(std::string const & e) { h_cite_engine = e; }
81 bool titleLayoutFound() const { return title_layout_found; }
83 void titleLayoutFound(bool found) { title_layout_found = found; }
84 /// Register an author named \p name in the author list
85 void registerAuthor(std::string const & name);
86 /// Get author named \p name (must be registered first)
87 Author const & getAuthor(std::string const & name) const;
88 /// Get number of arguments of special table column type \c or -1
89 /// if no column type \p c exists
90 int getSpecialTableColumnArguments(char c) const;
92 /// Parses the LaTeX preamble into internal data
93 void parse(Parser & p, std::string const & forceclass,
94 TeX2LyXDocClass & tc);
95 /// Writes the LyX file header from internal data
96 bool writeLyXHeader(std::ostream & os, bool subdoc);
98 /// known polyglossia language names (including variants)
99 static const char * const polyglossia_languages[];
100 /// the same as polyglossia_languages with .lyx names
101 static const char * const coded_polyglossia_languages[];
105 std::map<std::string, std::vector<std::string> > used_packages;
106 /// Packages that will be loaded automatically by LyX
107 std::set<std::string> auto_packages;
109 std::vector<std::string> used_modules;
111 /// needed to handle encodings with babel
113 /// the main non-CJK language
114 std::string default_language;
115 /// Was babel called explicitly?
118 /// was at least one title layout found?
119 bool title_layout_found;
121 std::ostringstream h_preamble;
122 std::string h_backgroundcolor;
123 std::string h_biblio_style;
124 std::string h_bibtex_command;
125 std::string h_boxbgcolor;
126 std::string h_cite_engine;
127 std::string h_cite_engine_type;
129 std::string h_defskip;
130 std::string h_float_placement;
131 std::string h_fontcolor;
132 std::string h_fontencoding;
133 std::string h_font_math;
134 std::string h_font_roman;
135 std::string h_font_sans;
136 std::string h_font_typewriter;
137 std::string h_font_default_family;
138 bool h_use_non_tex_fonts;
139 std::string h_font_sc;
140 std::string h_font_osf;
141 std::string h_font_sf_scale;
142 std::string h_font_tt_scale;
144 std::string h_font_cjk;
145 std::string h_graphics;
146 std::string h_default_output_format;
147 std::string h_html_be_strict;
148 std::string h_html_css_as_file;
149 std::string h_html_math_output;
150 std::string h_index[99];
151 std::string h_index_command;
152 std::string h_inputencoding;
153 std::string h_justification;
154 std::string h_language;
155 std::string h_language_package;
156 std::string h_listings_params;
157 std::string h_maintain_unincluded_children;
158 std::string h_margins;
159 std::string h_notefontcolor;
160 std::string h_options;
161 std::string h_output_changes;
162 std::string h_output_sync;
163 std::string h_output_sync_macro;
164 std::string h_papercolumns;
165 std::string h_paperfontsize;
166 std::string h_paperorientation;
167 std::string h_paperpagestyle;
168 std::string h_papersides;
169 std::string h_papersize;
170 std::string h_paragraph_indentation;
171 /// necessary to set the separation when \setlength is parsed
172 std::string h_paragraph_separation;
173 std::string h_pdf_title;
174 std::string h_pdf_author;
175 std::string h_pdf_subject;
176 std::string h_pdf_keywords;
177 std::string h_pdf_bookmarks;
178 std::string h_pdf_bookmarksnumbered;
179 std::string h_pdf_bookmarksopen;
180 std::string h_pdf_bookmarksopenlevel;
181 std::string h_pdf_breaklinks;
182 std::string h_pdf_pdfborder;
183 std::string h_pdf_colorlinks;
184 std::string h_pdf_backref;
185 std::string h_pdf_pdfusetitle;
186 std::string h_pdf_pagemode;
187 std::string h_pdf_quoted_options;
188 std::string h_quotes_language;
189 std::string h_secnumdepth;
190 std::string h_shortcut[99];
191 std::string h_spacing;
192 std::string h_suppress_date;
193 std::string h_textclass;
194 std::string h_tocdepth;
195 std::string h_tracking_changes;
196 std::string h_use_bibtopic;
197 std::string h_use_indices;
198 std::string h_use_geometry;
199 std::map<std::string, std::string> h_use_packages;
200 std::string h_use_default_options;
201 std::string h_use_hyperref;
205 * Add package \p name with options \p options to used_packages.
206 * Remove options from \p options that we don't want to output.
208 void add_package(std::string const & name,
209 std::vector<std::string> & options);
211 void handle_hyperref(std::vector<std::string> & options);
213 void handle_geometry(std::vector<std::string> & options);
215 void handle_package(Parser &p, std::string const & name,
216 std::string const & opts, bool in_lyx_preamble);
218 void handle_if(Parser & p, bool in_lyx_preamble);
222 /// special table column types
223 std::map<char, int> special_columns_;
227 extern Preamble preamble;