* de/Tutorial.lyx: minor corrections reported on lyx-docs.
[lyx.git] / src / LaTeX.h
blob78c283d85a6fb6c350a9c1dcc3f80cfb872c4db5
1 // -*- C++ -*-
2 /**
3 * \file LaTeX.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Angus Leeming
9 * \author Dekel Tsur
11 * Full author contact details are available in file CREDITS.
14 #ifndef LATEX_H
15 #define LATEX_H
17 #include "OutputParams.h"
19 #include "support/docstring.h"
20 #include "support/FileName.h"
22 #include <boost/noncopyable.hpp>
23 #include <boost/signal.hpp>
25 #include <vector>
26 #include <set>
29 namespace lyx {
31 class DepTable;
33 ///
34 class TeXErrors {
35 private:
36 ///
37 class Error {
38 public:
39 ///
40 Error () : error_in_line(0) {}
41 ///
42 Error(int line, docstring const & desc, docstring const & text)
43 : error_in_line(line),
44 error_desc(desc),
45 error_text(text) {}
46 /// what line in the TeX file the error occured in
47 int error_in_line;
48 /// The kind of error
49 docstring error_desc;
50 /// The line/cmd that caused the error.
51 docstring error_text;
53 public:
54 ///
55 typedef std::vector<Error> Errors;
56 ///
57 Errors::const_iterator begin() const { return errors.begin(); }
58 ///
59 Errors::const_iterator end() const { return errors.end(); }
60 ///
61 void insertError(int line, docstring const & error_desc,
62 docstring const & error_text);
63 private:
64 ///
65 Errors errors;
69 class AuxInfo {
70 public:
71 ///
72 AuxInfo() {}
73 ///
74 support::FileName aux_file;
75 ///
76 std::set<std::string> citations;
77 ///
78 std::set<std::string> databases;
79 ///
80 std::set<std::string> styles;
84 ///
85 bool operator==(AuxInfo const &, AuxInfo const &);
86 bool operator!=(AuxInfo const &, AuxInfo const &);
89 /**
90 * Class to run the LaTeX compiler and needed auxiliary programs.
91 * The main .tex file must be in the current directory. The current directory
92 * must not change as long as an object of this class lives.
93 * This is required by the LaTeX compiler, and we also make use of it by
94 * various support::makeAbsPath() calls.
96 class LaTeX : boost::noncopyable {
97 public:
98 /** Return values from scanLogFile() and run() (to come)
100 This enum should be enlarged a bit so that one could
101 get more feedback from the LaTeX run.
103 enum log_status {
105 NO_ERRORS = 0,
107 NO_LOGFILE = 1,
109 NO_OUTPUT = 2,
111 UNDEF_REF = 4, // Reference '...' on page ... undefined.
113 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
115 RERUN = 16, // Label(s) may have changed. Rerun to get...
117 TEX_ERROR = 32,
119 TEX_WARNING = 64,
121 LATEX_ERROR = 128,
123 LATEX_WARNING = 256,
125 PACKAGE_WARNING = 512,
127 NO_FILE = 1024,
129 NO_CHANGE = 2048,
131 TOO_MANY_ERRORS = 4096,
133 ERROR_RERUN = 8192,
135 ERRORS = TEX_ERROR + LATEX_ERROR,
137 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
140 /// This signal emits an informative message
141 boost::signal<void(docstring)> message;
145 cmd = the latex command, file = name of the (temporary) latex file,
146 path = name of the files original path.
148 LaTeX(std::string const & cmd, OutputParams const &,
149 support::FileName const & file);
151 /// runs LaTeX several times
152 int run(TeXErrors &);
155 int getNumErrors() { return num_errors;}
158 int scanLogFile(TeXErrors &);
160 private:
161 /// use this for running LaTeX once
162 int startscript();
164 /// The dependency file.
165 support::FileName depfile;
168 void deplog(DepTable & head);
171 bool runMakeIndex(std::string const &, OutputParams const &,
172 std::string const & = std::string());
175 bool runMakeIndexNomencl(support::FileName const &,
176 std::string const &, std::string const &);
179 std::vector<AuxInfo> const scanAuxFiles(support::FileName const &);
182 AuxInfo const scanAuxFile(support::FileName const &);
185 void scanAuxFile(support::FileName const &, AuxInfo &);
188 void updateBibtexDependencies(DepTable &, std::vector<AuxInfo> const &);
191 bool runBibTeX(std::vector<AuxInfo> const &, OutputParams const &);
194 void deleteFilesOnError() const;
197 std::string cmd;
200 support::FileName file;
202 /// used by scanLogFile
203 int num_errors;
205 /// The name of the final output file.
206 support::FileName output_file;
209 OutputParams runparams;
213 } // namespace lyx
215 #endif