From b4f67057ab6d2e698db46e20011c35a812e017cc Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 14 Jul 2019 09:41:17 +0200 Subject: [PATCH] tex2lyx: lineno support --- src/tex2lyx/Preamble.cpp | 17 ++++++++++++++--- src/tex2lyx/Preamble.h | 2 ++ src/tex2lyx/TODO.txt | 1 - 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 336a939dd2..3dc53c9638 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -504,8 +504,7 @@ string remove_braces(string const & value) Preamble::Preamble() : one_language(true), explicit_babel(false), - title_layout_found(false), index_number(0), h_font_cjk_set(false), - h_use_microtype("false") + title_layout_found(false), index_number(0), h_font_cjk_set(false) { //h_backgroundcolor; //h_boxbgcolor; @@ -599,6 +598,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false), h_use_default_options = "false"; h_use_hyperref = "false"; h_use_microtype = "false"; + h_use_lineno = "false"; h_use_refstyle = false; h_use_minted = false; h_use_packages["amsmath"] = "1"; @@ -1486,6 +1486,14 @@ void Preamble::handle_package(Parser &p, string const & name, h_preamble << "\\usepackage[" << opts << "]{microtype}"; } + else if (name == "lineno") { + h_use_lineno = "true"; + if (!options.empty()) { + h_lineno_options = join(options, ","); + options.clear(); + } + } + else if (!in_lyx_preamble) { if (options.empty()) h_preamble << "\\usepackage{" << name << '}'; @@ -1678,7 +1686,10 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled << "\\suppress_date " << h_suppress_date << '\n' << "\\justification " << h_justification << '\n' << "\\use_refstyle " << h_use_refstyle << '\n' - << "\\use_minted " << h_use_minted << '\n'; + << "\\use_minted " << h_use_minted << '\n' + << "\\use_lineno " << h_use_lineno << '\n'; + if (!h_lineno_options.empty()) + os << "\\lineno_options " << h_lineno_options << '\n'; if (!h_fontcolor.empty()) os << "\\fontcolor " << h_fontcolor << '\n'; if (!h_notefontcolor.empty()) diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h index 1130ad2d5b..0ec2b4581f 100644 --- a/src/tex2lyx/Preamble.h +++ b/src/tex2lyx/Preamble.h @@ -178,6 +178,8 @@ private: bool h_font_cjk_set; std::string h_font_cjk; std::string h_use_microtype; + std::string h_use_lineno; + std::string h_lineno_options; std::string h_is_mathindent; std::string h_math_numbering_side; std::string h_mathindentation; diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index 55c57f3949..3c6693e315 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -34,7 +34,6 @@ Format LaTeX feature LyX feature 443 unicode-math.sty InsetMath* 453 automatic stmaryrd loading \use_package stmaryrd 457 automatic stackrel loading \use_package stackrel -575 numbering of lines (lineno) \use_lineno, \lineno_options General -- 2.39.5