3

I'm beginner in LyX and I have a problem. In 'LyX: box' the option "allow page breaks' is not available. What can I do?

Werner
  • 603,163

1 Answers1

6

LyX's Insert > Box options all set unbreakable boxes. You'll have to create a custom inset to manage something the provides breakable boxes. One package that provides this is mdframed. So, let's set up a custom inset that uses mdframed:

  1. Set up the environment that you're going to use. For this, add the following to your Document > Settings... > LaTeX Preamble:

    \usepackage[framemethod=tikz]{mdframed}
    
    \newmdenv[
      hidealllines=true,
      backgroundcolor=blue!20,
      innerleftmargin=3pt,
      innerrightmargin=3pt,
      leftmargin=-3pt,
      rightmargin=-3pt
    ]{shadedbox}
    

    The above code loads the mdframed package and also sets up an environment called shadedbox with the given parameters. You can read the mdframed documentation to see exactly the meaning of them all, and redefine it to make it your own. I chose an example from How to highlight an entire paragraph?.

  2. Now set up Document > Settings... > Local Layout that uses the environment defined above:

    Format 60
    
    InsetLayout Flex:Shaded_Box
      LyXType           custom
      LabelString       "Shaded Box"
      LatexType     Environment
      LatexName     shadedbox
      Decoration        Classic
      MultiPar              true
      CustomPars        true
      ResetsFont        true
      LabelFont
        Color               foreground
        Size                Small
      EndFont
    End
    

    This adds "Shaded Box" to your Insert > Custom Inset menu item:

    enter image description here

  3. Use it like you mean it!

    enter image description here

You'll have to understand how to change the settings of the environment to make it suit your needs. One could also add an optional argument to make small, local modifications if needed.

Werner
  • 603,163