From 5449a5b83789a1d36a01d1f7ce80feaf8cd1567a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Mon, 18 May 2015 00:56:23 +0200 Subject: [PATCH] tex2lyx/text.cpp: support for the commands \fboxsep etc. It is impossible handle all cases because the closing brace of an \fboxsep block can be everywhere. Therefore the braces remain in ERT. --- .../test/box-color-size-space-align.tex | 12 +++++ src/tex2lyx/text.cpp | 51 ++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/tex2lyx/test/box-color-size-space-align.tex b/src/tex2lyx/test/box-color-size-space-align.tex index ab658c62c2..b004eedbbd 100644 --- a/src/tex2lyx/test/box-color-size-space-align.tex +++ b/src/tex2lyx/test/box-color-size-space-align.tex @@ -157,6 +157,18 @@ blabla \doublebox{doublebox} blabla $\boxed{\int A=B}$ +\subsection{Boxes with custom settings} + +\fboxsep 35pt + +\framebox[1cm]{www} + +\fboxsep 20pt \framebox[1cm]{www} + +{\fboxsep 1pt \fboxrule 10pt \framebox[1cm]{www}} + +{\fboxsep 35pt\shadowsize 15pt\shadowbox{\centering www}} + \subsection{Color Boxes} \colorbox{blue}{www} diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 2ed73959bd..9f1dd5d9b0 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -124,6 +124,9 @@ string parse_text_snippet(Parser & p, unsigned flags, const bool outer, return os.str(); } +string fboxrule = ""; +string fboxsep = ""; +string shadow_size = ""; char const * const known_ref_commands[] = { "ref", "pageref", "vref", "vpageref", "prettyref", "nameref", "eqref", 0 }; @@ -849,8 +852,20 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags, string latex_width; string width_special = "none"; string thickness = "0.4pt"; - string separation = "3pt"; - string shadowsize = "4pt"; + if (fboxrule != "") + thickness = fboxrule; + else + thickness = "0.4pt"; + string separation; + if (fboxsep != "") + separation = fboxsep; + else + separation = "3pt"; + string shadowsize; + if (shadow_size != "") + shadowsize = shadow_size; + else + shadowsize = "4pt"; string framecolor = "black"; string backgroundcolor = "none"; if (frame_color != "") @@ -1190,6 +1205,17 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags, // in this case we have to eat the the closing brace of the color box p.get_token().asInput(); // the '}' } + if (p.next_token().asInput() == "}" + && (fboxrule != "" || fboxsep != "" || shadow_size != "")) { + // in this case we assume that the closing brace is from the box settings + // therefore reset these values for the next box + if (fboxrule != "") + fboxrule = ""; + if (fboxsep != "") + fboxsep = ""; + if (shadow_size != "") + shadow_size = ""; + } } @@ -4206,6 +4232,27 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, parse_box(p, os, 0, 0, outer, context, "", "", "", "", backgroundcolor); } + else if (t.cs() == "fboxrule" || t.cs() == "fboxsep" + || t.cs() == "shadowsize") { + p.skip_spaces(true); + if (t.cs() == "fboxrule") + fboxrule = ""; + if (t.cs() == "fboxsep") + fboxsep = ""; + if (t.cs() == "shadowsize") + shadow_size = ""; + while (p.good() && p.next_token().cat() != catSpace + && p.next_token().cat() != catNewline + && p.next_token().cat() != catEscape) { + if (t.cs() == "fboxrule") + fboxrule = fboxrule + p.get_token().asInput(); + if (t.cs() == "fboxsep") + fboxsep = fboxsep + p.get_token().asInput(); + if (t.cs() == "shadowsize") + shadow_size = shadow_size + p.get_token().asInput(); + } + } + //\framebox() is part of the picture environment and different from \framebox{} //\framebox{} will be parsed by parse_outer_box else if (t.cs() == "framebox") { -- 2.39.2