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.
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.
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.
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.)
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.)
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.
Go to Document --> Settings --> Document class, and add demo
to the Custom class options. This should replace the images with black rectangles.
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:
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).
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.