Is there a proper way to post a MWE when using LyX instead of LaTeX proper?

The commonly used comment requesting a MWE is confusing to me when using LyX.

1 Answer 1


The basic principle is exactly the same whether you use LaTeX (I've just been asked to write a minimal example, what is that?) or LyX: create a document that contains the least amount of content possible, while still demonstrating the problem at hand.

For example, if you have a problem with a table, you can probably remove all the text in the document, except for the table itself. If you have added anything to Document --> Settings --> LaTeX preamble that doesn't influence tables in any way, you can remove that as well. The LyX Wiki has a page about this as well: http://wiki.lyx.org/FAQ/MinimalExample

A key point is to make sure that your MWE is able to reproduce the problem. If it is an error you're wondering about, then trying to create a PDF from the MWE should generate that error. So test your MWE before adding it to a post.

Adding the MWE to a post

There are two options, you can either add the .lyx file itself, or the exported LaTeX source. If this is some LyX specific issue, then the former is better I suppose. The benefit of the latter is that more people will be able to answer, the disadvantage is that you may need to 'translate' the answer to LyX.

  1. Adding the .lyx file. You cannot upload files to posts on StackExchange, but as a .lyx file is actually just a plain text file, you can open it in a text editor, and copy-paste the lot.

    Exactly how you do this depends on operating system, but typically you right click on the file, choose Open with and then a text editor, such as Gedit, Kate or Notepad. (Or you open the .lyx file from the editor.)

  2. Adding exported LaTeX source. In LyX, do File --> Export --> LaTeX (pdfLaTeX). This will generate a .tex file in the same folder as the .lyx file. Open it, and copy-paste the contents into your post

(In both cases, add syntax highlighting by selecting the entire code block and clicking the {} button above the text field, or hitting Ctrl + K.)

What do I do about images?

If images are required for your example, remember that we don't have access to the. There are a few things you can do instead.

  1. Go to Document --> Settings --> Document class, and add demo to the Custom class options. This should replace the images with black rectangles.

  2. Use the images from the mwe package. If that package is installed, you will have images called example-image, example-image-a, example-image-b, example-image-c, example-image-16x10, example-image-10x16, and a few more (see the package documentation). Each is available in several formats.

    In LyX, write just the name of one of these, without a file ending, like so:

    enter image description here

    The image will not show in LyX, but it will appear in the PDF. If a specific size is required for the example, specify this.

    (It is not necessary to add \usepackage{mwe} to the preamble).

  3. Replace the image with an ERT containing e.g. \rule{3cm}{2cm} which creates a black rectangle that is 3cm wide and 2cm high. Modify the size if needed.

  • Is something to be said about the problematic nature of reverse engineering a working LyX file from a LaTeX source file ?
    – 1010011010
    Commented Jun 27, 2014 at 22:05
  • @1010011010 I'm not sure what I could say about it, whether it's problematic or not depends on the file. If you have anything to add on that, feel free to write an answer, or even edit mine. Commented Jun 28, 2014 at 7:49

You must log in to answer this question.

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