2

Before I resolved a problem to set up a minted environment in LaTeX. Now, I would like to add this environment as a LyX layout. I have tried with

Style MatlabCode
Category              MainText
Margin                Static
LatexType             Environment
LatexName             matlabcode
NextNoIndent          1
LeftMargin            MMM
RightMargin           MMM
ParIndent             MM
ParSkip               0
ItemSep               0
TopSep                0.5
BottomSep             0.5
ParSep                0
Align                 Block
AlignPossible         Block, Left, Right, Center
Preamble
    \usepackage{minted}
    \newminted{matlab}{mathescape,linenos=true}
EndPreamble

End

Everything works and pdflatex gives me a nice PDF. The problem is that, when I use the environment, which is similar to a quotation layout in LyX, in the output I get blank lines, like this

enter image description here

And those weird brackets, since it should be just [2;3]

Does anyone know about this?

8
  • Can you please post a LyX minimal example ? In this case that would be a LyX file with a Local Layout that you pasted in here and that produces the output that you pasted here.
    – scottkosty
    Commented Oct 17, 2013 at 22:26
  • Hi, here there is an example dropbox.com/sh/8b4tp1ho94z41ok/9VwyKZjego Remember to put -shell-escape in the pdflatex option in the Tools -> Preferences
    – PerroNoob
    Commented Oct 17, 2013 at 22:39
  • I put also the layouts file. You must reconfigure LyX after leaving that file in the layouts directory
    – PerroNoob
    Commented Oct 17, 2013 at 22:43
  • 2
    Thanks for the minimal example. Note that you might be interested to know that you could just put your layout directly in Document > Settings > Local Layout. This is useful when developing your layout (e.g. making a lot of tweaks), useful for document-specific layouts (which this will probably not be), and also useful for minimal examples (no need for reconfigure and just one file).
    – scottkosty
    Commented Oct 17, 2013 at 23:21
  • 1
    I was giving you advice for how to improve on posting a minimal example. You should always give the prerequisites that are necessary (in this case the pygmentize package). And using LyX's local layout is useful for encapsulating things. I'm not referring to ~/.lyx. That is something different. I'm referring to Document > Settings > Local Layout. If you put the layout in there, everything is self-contained and it makes it easy for someone to come along and try to help. It's also useful for other reasons.
    – scottkosty
    Commented Oct 18, 2013 at 16:52

1 Answer 1

2

You need to add the following lines:

PassThru                      1
ParbreakIsNewline             1

PassThru tells LyX "don't escape my input. It's not LaTeX".

`ParbreakIsNewline tells LyX not to start a new paragraph for line breaks in this layout.

This gives the following layout:

Style MatlabCode
Category              MainText
Margin                Static
LatexType             Environment
LatexName             matlabcode
NextNoIndent          1
LeftMargin            MMM
RightMargin           MMM
PassThru              1
ParbreakIsNewline             1
ParIndent             MM
ParSkip               0
ItemSep               0
TopSep                0.5
BottomSep             0.5
ParSep                0
Align                 Block
AlignPossible         Block, Left, Right, Center
Preamble
        \usepackage{minted}
        \newminted{matlab}{mathescape,linenos=true}
    EndPreamble
End

Please read Help > Customization for more information.

1
  • Thanks a lot. I'll take a look to the Help, I didn't find that information before.
    – PerroNoob
    Commented Oct 18, 2013 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .