From c90e02ff0d0a764fee622999fcc45ec8dd3b07f1 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 6 May 2012 18:47:53 +0200 Subject: [PATCH] Import table cells in sideways environment. This is a part of bug #8081: Translate cells in \begin{sideways}...\end{sideways} to native syntax. The turn environment comes in a later commit, since this one os suitable for backporting. --- src/tex2lyx/Preamble.cpp | 6 +++--- src/tex2lyx/table.cpp | 26 +++++++++++++++++++++++++- src/tex2lyx/test/test-insets.tex | 3 ++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 5dbd9f3a66..c02c1919c4 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -173,9 +173,9 @@ const char * const known_xetex_packages[] = {"arabxetex", "fixlatvian", /// packages that are automatically skipped if loaded by LyX const char * const known_lyx_packages[] = {"amsbsy", "amsmath", "amssymb", -"amstext", "amsthm", "array", "booktabs", "calc", -"color", "float", "graphicx", "hhline", "ifthen", "longtable", "makeidx", -"multirow", "nomencl", "pdfpages", "rotfloat", "splitidx", "setspace", +"amstext", "amsthm", "array", "booktabs", "calc", "color", "float", +"graphicx", "hhline", "ifthen", "longtable", "makeidx", "multirow", +"nomencl", "pdfpages", "rotating", "rotfloat", "splitidx", "setspace", "subscript", "textcomp", "ulem", "url", "varioref", "verbatim", "wrapfig", 0}; // codes used to remove packages that are loaded automatically by LyX. diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp index bed513c08b..9e212b404c 100644 --- a/src/tex2lyx/table.cpp +++ b/src/tex2lyx/table.cpp @@ -1194,11 +1194,35 @@ void handle_tabular(Parser & p, ostream & os, string const & name, for (size_t c = 1; c < colinfo.size(); ++c) cellinfo[row][c].multi = CELL_PART_OF_MULTICOLUMN; } else { + bool sideways = false; + if (p.next_token().cs() == "begin") { + p.pushPosition(); + p.get_token(); + string const env = p.getArg('{', '}'); + if (env == "sideways") { + active_environments.push_back(env); + p.verbatimEnvironment(env); + active_environments.pop_back(); + p.skip_spaces(); + if (!p.good()) + sideways = true; + } + p.popPosition(); + } cellinfo[row][col].leftlines = colinfo[col].leftlines; cellinfo[row][col].rightlines = colinfo[col].rightlines; cellinfo[row][col].align = colinfo[col].align; ostringstream os; - parse_text_in_inset(p, os, FLAG_CELL, false, context); + if (sideways) { + cellinfo[row][col].rotate = 90; + p.get_token(); + active_environments.push_back(p.getArg('{', '}')); + parse_text_in_inset(p, os, FLAG_END, false, context); + active_environments.pop_back(); + preamble.registerAutomaticallyLoadedPackage("rotating"); + } else { + parse_text_in_inset(p, os, FLAG_CELL, false, context); + } cellinfo[row][col].content += os.str(); } } diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex index 30ecd0f395..745e4b86f0 100644 --- a/src/tex2lyx/test/test-insets.tex +++ b/src/tex2lyx/test/test-insets.tex @@ -27,6 +27,7 @@ \usepackage{longtable} \usepackage{xargs} \usepackage{subscript} +\usepackage{rotating} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. \providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@} @@ -375,7 +376,7 @@ A table*: \begin{tabular*} % some comment {0.8\columnwidth}[b]{lr} two\\ -lonely&lines +lonely&\begin{sideways}lines\end{sideways} \end{tabular*} A booktabs table: -- 2.39.2