X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Foutput_latex.cpp;h=47ae3f8be74a2dd9fcf3925bac50b581cbd7460e;hb=8c6ac457ecc69f57ab54cd8c9b8b7893607c65d6;hp=8532b403fa7559736a7de6885869cf03059391fd;hpb=5ddc612b735317d5b22553a63aad7879503e3950;p=lyx.git diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 8532b403fa..47ae3f8be7 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -14,7 +14,7 @@ #include "Buffer.h" #include "BufferParams.h" -#include "debug.h" +#include "support/debug.h" #include "Encoding.h" #include "InsetList.h" #include "Language.h" @@ -24,6 +24,7 @@ #include "Paragraph.h" #include "paragraph_funcs.h" #include "ParagraphParameters.h" +#include "TextClass.h" #include "TexRow.h" #include "VSpace.h" @@ -69,7 +70,7 @@ TeXDeeper(Buffer const & buf, odocstream & os, TexRow & texrow, OutputParams const & runparams) { - LYXERR(Debug::LATEX) << "TeXDeeper... " << &*pit << endl; + LYXERR(Debug::LATEX, "TeXDeeper... " << &*pit); ParagraphList::const_iterator par = pit; while (par != paragraphs.end() && @@ -82,7 +83,7 @@ TeXDeeper(Buffer const & buf, os, texrow, runparams); } } - LYXERR(Debug::LATEX) << "TeXDeeper...done " << endl; + LYXERR(Debug::LATEX, "TeXDeeper...done "); return par; } @@ -95,7 +96,7 @@ TeXEnvironment(Buffer const & buf, odocstream & os, TexRow & texrow, OutputParams const & runparams) { - LYXERR(Debug::LATEX) << "TeXEnvironment... " << &*pit << endl; + LYXERR(Debug::LATEX, "TeXEnvironment... " << &*pit); BufferParams const & bparams = buf.params(); @@ -116,7 +117,8 @@ TeXEnvironment(Buffer const & buf, lyxrc.language_command_end, "$$lang", prev_par_language->babel())) - << '\n'; + // the '%' is necessary to prevent unwanted whitespace + << "%\n"; texrow.newline(); } @@ -127,7 +129,8 @@ TeXEnvironment(Buffer const & buf, lyxrc.language_command_begin, "$$lang", par_language->babel())) - << '\n'; + // the '%' is necessary to prevent unwanted whitespace + << "%\n"; texrow.newline(); } } @@ -210,9 +213,9 @@ TeXEnvironment(Buffer const & buf, texrow.newline(); } - if (par != paragraphs.end()) { - LYXERR(Debug::LATEX) << "TeXEnvironment...done " << &*par << endl; - } + if (par != paragraphs.end()) + LYXERR(Debug::LATEX, "TeXEnvironment...done " << &*par); + return par; } @@ -248,21 +251,24 @@ TeXOnePar(Buffer const & buf, OutputParams const & runparams_in, string const & everypar) { - LYXERR(Debug::LATEX) << "TeXOnePar... " << &*pit << " '" - << everypar << "'" << endl; + LYXERR(Debug::LATEX, "TeXOnePar... " << &*pit << " '" + << everypar << "'"); BufferParams const & bparams = buf.params(); LayoutPtr style; if (runparams_in.verbatim) { - Font const outerfont = - outerFont(std::distance(paragraphs.begin(), pit), - paragraphs); + int const dist = std::distance(paragraphs.begin(), pit); + Font const outerfont = outerFont(dist, paragraphs); + + // No newline if only one paragraph in this lyxtext + if (dist > 0) { + os << '\n'; + texrow.newline(); + } /*bool need_par = */ pit->latex(buf, bparams, outerfont, os, texrow, runparams_in); - os << '\n'; - texrow.newline(); return ++pit; } @@ -280,7 +286,7 @@ TeXOnePar(Buffer const & buf, Language const * const par_language = pit->getParLanguage(bparams); // The document's language Language const * const doc_language = bparams.language; - // The language that was in effect when the environemnt this paragraph is + // The language that was in effect when the environment this paragraph is // inside of was opened Language const * const outer_language = (runparams.local_font != 0) ? @@ -307,7 +313,8 @@ TeXOnePar(Buffer const & buf, os << from_ascii(subst(lyxrc.language_command_end, "$$lang", prev_language->babel())) - << '\n'; + // the '%' is necessary to prevent unwanted whitespace + << "%\n"; texrow.newline(); } @@ -360,7 +367,8 @@ TeXOnePar(Buffer const & buf, lyxrc.language_command_begin, "$$lang", par_language->babel())) - << '\n'; + // the '%' is necessary to prevent unwanted whitespace + << "%\n"; texrow.newline(); } } @@ -390,7 +398,8 @@ TeXOnePar(Buffer const & buf, if (encoding->package() == Encoding::inputenc && enc_switch.first) { runparams.encoding = encoding; if (enc_switch.second > 0) { - os << '\n'; + // the '%' is necessary to prevent unwanted whitespace + os << "%\n"; texrow.newline(); } } @@ -602,9 +611,8 @@ TeXOnePar(Buffer const & buf, texrow.newline(); } - if (boost::next(pit) != paragraphs.end()) { - LYXERR(Debug::LATEX) << "TeXOnePar...done " << &*boost::next(pit) << endl; - } + if (boost::next(pit) != paragraphs.end()) + LYXERR(Debug::LATEX, "TeXOnePar...done " << &*boost::next(pit)); return ++pit; } @@ -730,14 +738,13 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, || newEnc.package() == Encoding::none) return make_pair(false, 0); - LYXERR(Debug::LATEX) << "Changing LaTeX encoding from " - << oldEnc.name() << " to " - << newEnc.name() << endl; + LYXERR(Debug::LATEX, "Changing LaTeX encoding from " + << oldEnc.name() << " to " << newEnc.name()); os << setEncoding(newEnc.iconvName()); if (bparams.inputenc == "default") return make_pair(true, 0); - docstring const inputenc(from_ascii(newEnc.latexName())); + docstring const inputenc = from_ascii(newEnc.latexName()); switch (newEnc.package()) { case Encoding::none: // shouldn't ever reach here, see above @@ -750,7 +757,7 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, } os << "\\inputencoding{" << inputenc << '}'; return make_pair(true, count + 16); - } + } case Encoding::CJK: { int count = inputenc.length(); if (oldEnc.package() == Encoding::CJK) {