# What is the difference between LyX and LaTeX?

Currently I am using LaTeX to typeset all my math reports. Recently I found out that LyX also uses LaTeX, which can also generate PDF, accept commands from LaTeX, but is easier to use as it does not flood all the commands in one page.

Question: What is the difference between LyX and LaTeX?

-
LyX is an editor which can run the source with LaTeX, ConTeXt, or whatever. So it is not the question "LyX or LaTeX" it is "LyX or TeXmaker or ..." –  Herbert Aug 25 '14 at 5:48
Actually LyX is a kind of compatibility layer on LaTeX that let you use it like a text processor under the logic WYSIWYG. Personally I don't enjoy it, for me is worse for type maths and for use it well sometimes you need deeper LaTeX knowledge for make some adjustments. Below LyX can be LaTeX or ConTeXt, as @Herbert said. –  Aradnix Aug 25 '14 at 6:01
@Herbert Where does ConTeXt fit in? LyX only produces LaTeX code. (And IMO LyX isn't really the same as Texmaker etc., in the latter you write the code yourself, in the former (most of) the code is generated automatically, and you don't have complete control of the code unless you export and edit.) –  Torbjørn T. Aug 25 '14 at 9:26
When I started on LaTeX I though LyX sounded like a nice easy way in, but I found it frustratingly awkward. This stopped almost instantly went I started working on the code directly, and that's editor-independent. But I'm used to writing bits of code. –  Chris H Aug 25 '14 at 14:42
There is an objective part in your question (Are there differences in the pdf-outputs? What are the differences?), but your title is attracting highly opinion-based answers. Can you make some adjustments? So far only one (out of six) addresses the real question. –  Johannes_B Aug 26 '14 at 7:57

I always recommend that you learn the basics of LaTeX before you learn LyX. LyX will not save you from learning LaTeX so you might as well learn it well from the start. After you really understand what LyX is doing (through LaTeX), you might find you like it better than using LaTeX directly. This is the case for me. This is also why I don't think LyX is a software for newbies. I think it should be used by advanced LaTeX users who understand what they're delegating to LyX and how to step in to take control when they want to. But many people disagree with me on that.

My main point: I don't think you should try to learn LyX instead of learning LaTeX. That would be a mistake in my opinion.

-

Q: What is the difference between LyX and LaTeX?

A: From the LyX website:

LyX is a document processor that encourages an approach to writing based on the structure of your documents (WYSIWYM) and not simply their appearance (WYSIWYG).

LyX combines the power and flexibility of TeX/LaTeX with the ease of use of a graphical interface. This results in world-class support for creation of mathematical content (via a fully integrated equation editor) and structured documents like academic articles, theses, and books. In addition, staples of scientific authoring such as reference list and index creation come standard. But you can also use LyX to create a letter or a novel or a theatre play or film script. A broad array of ready, well-designed document layouts are built in.

LyX is a document processor which merely acts as an interface to LaTeX. While it does strip the user from many LaTeX-related handles, it has its drawbacks, many of which can be solved via ERT-specific injections. That is, you insert LaTeX code where it's needed.

Q: Is there any difference between the PDF generated by LyX and LaTeX?

A: There shouldn't be, since LyX can be installed to use drivers from an existing TeX setup.

Q: Which one should I use between LyX and LaTeX?

A: Depends on your preference and experience. I would go with LaTeX since I'm okay with seeing code rather than the LyX display.

-

LyX provides a more user-friendly front-end to latex.

I find it more productive to work in general in LyX. However, by its nature it is not as flexible as pure latex.

I do have to sometimes use LaTeXcode to achieve the desired results in LyX. That can be achieved either by setting things up in the document preamble or inserting latex code directly into the LyX document, depending on the situation.

Largely it is a matter of expertise, and then preference. IMHO, LyX doesn't remove the need to understand LaTeX, but reduces the steepness of the initial learning curve.

-
Sorry, but this answer is so much opinion-based (and therefore unsuitable for StackExchange). WYSIWYG is the biggest bullexcrement ever, including LyX, W@#d, Gmail's "new mail" window, ... –  yo' Aug 26 '14 at 7:58
@tohecz Sorry, but this comment is so much opinion-based... :p Nah, you're right of course. –  Jubobs Aug 26 '14 at 8:22
@Jubobs That's the intention: to make an opinion-based comment showing that this answer simply cannot be "correct". –  yo' Aug 26 '14 at 8:41

Here is, I think, a fairly objective distinction between using LyX and editing LaTeX directly:

• LyX is very good at exporting to LaTeX. If you create a document in LyX with sections and theorems and equations then the PDF you create will be just as if you wrote it in LaTeX, because that's exactly what LyX did for you.
• LyX is extremely bad at importing from LaTeX. Unlike what Herbet said, you cannot just edit any old LaTeX document with LyX and expect good results. So if you want to collaborate with an author that does not use LyX, or wish to edit a document and not spend the one-time cost of tidying up the result of an import, then LyX is not suitable.

I'm sure you'll have no shortage of people sharing their subjective opinions of LyX, but I'll add in mine:

• I agree with scottkosty that using LyX will not avoid having to learn LaTeX. You will end up needing to understand what LyX is doing under the covers. But, IMHO, this effort is worth it for the time saved in creating/editing the content of documents.
• However, writing and editing a document with LyX is MUCH quicker than editing LaTeX, even if you know what you're doing, for several reasons:
• There is so much visual clutter (\begin{theorem}, \emph etc) that you can focus on the content.
• Editing equations visually is much easier, especially with lots of super/subscripts. In LaTeX these less important elements dominate the equation's code. I find people deal with this by constantly LaTeXing their document and examining the PDF, which is a huge waste of time compared to editing the equation directly.
• You do not constantly need to run LaTeX to check that you have not missed a closing brace etc. Again, many LaTeX users (even those that claim they don't!) typeset their document very frequently to catch these quickly; I often spend days or even weeks editing a LyX document without typesetting to PDF.
-
LaTeX and Maths: It takes some thinking and getting used to, but writing maths in LaTeX is fairly easy when one knows what to write... - And I have typeset a fair bit of maths in it. At least it isn't any more difficult than a WYSIWYG editor. (In fact, I consider the latter annoying because you can easily forget leaving a sub- or superscript...) –  DetlevCM Aug 25 '14 at 12:49
@DetlevCM If you can forget to leave a sub- or superscript in a WYSIWYG editor, you can surely forget it in LaTeX! But then instead of seeing the cursor in an odd position, you don't notice the problem until you typeset and that missing } causes a runaway error (but which { is to blame?). Anyway, it is not the writing that is faster in LyX, it is the editing. You may get very used to reading x^\beta, but it will never be quite as clear as the literal maths (especially when a less-important script visually dominates). –  Jim Oldfield Aug 25 '14 at 22:57
@Jim Speak for yourself. Once you start doing hundreds of pages of LaTeX files a month, it gets different, like this: youtube.com/watch?v=3vAnuBtyEYE –  yo' Aug 26 '14 at 7:54
@tohecz You are... the One! –  Jubobs Aug 26 '14 at 17:43
I totally agree with tohecz. First, most of the editors have this nice auto-completion property which saves typing time. Second, if you get used to read code, you'll always find a super/subscript problem. Try to debug nested super/subscripts in a big equation only from PDF! –  Claudio Fiandrino Aug 27 '14 at 8:08

I think all the important points have been covered, but there is one more aspect I would consider when looking at LaTeX (or even a programming language, photo editor, etc.).

"How important is the interface, what do I do if it dies?"

In the context of LyX and LaTeX, LaTeX really just needs its compiler and some text editor, the latter we can be certain will exist pretty much as long as computers exist. When you use software such as LyX, you invariably end up being tied to the interface because it uses its own file format for storing its information.

Most OpenSource projects (with a large user base) can be relied on to exist for a long time, but that still isn't a guarantee things may not change or the project might not fall dormant at some point.

Using LaTeX directly reduces one point of failure - it is the user and LaTeX only that are needed.

-

LyX produce a LaTeX file and then call to pdflatex (or other compiler) to produce the PDF with this LaTeX file, so the results is the same. The point is decide if you are more comfortable editing directly the LaTeX source or the Lyx document.

No doubt, LyX is much more attractive than LaTeX for novices because is a WYSIWYM editor (see Werner answer) where is relatively easy to produce some documents without any experience. But this is rather a disadvantage than a advantage in a long-term, because hiding what happen behind the scenes prevents to understand how LaTeX works in the very first steps. Before or later, you will need a good LaTeX knowledge in order to make a custom preamble or add some complex LaTeX code that cannot be managed directly by LyX. Instead, starting with LaTeX you will have a hard initial learning curve, but you will understand quickly the LaTeX document structure and soon you will realize that use texdoc profusely is a must.

Another great advantage of LyX is that prevent many writing code errors and common mistakes. But some day, for some odd reason, you will produce a non compilable LaTeX code with your nice WYSIWYM editor. Then the LyX file is a source of frustration. The solution could be very obscure for the naive LyX user (in spite of the "nice" TeX error messages) because you have no idea of what is wrong in the LaTeX source code nor even wich part ot the code is producing the error. Horror! But you need to print your 200 pages document for tomorrow morning, but suddenly LyX refuses to produce the damn PDF! What now? Even if the problem is identified correctly, you still need to guess how prevent this using the WYSIWYM environment (you can see the generated source code, but you cannot modify it directly).

On the other hand, the LaTeX user quickly learn that any mistyped command or wrong command sequence have serious consequences, so delimit the source of the problem, search & find the offending become a simple routine after some time (well, in most cases). Some LaTeX editors help a lot with this task, so, noo panic if you obtain a "undefined control sequence"!

LyX have the great feature of hide/unhide the content of ERT boxes as well as index entries, cites, etc. but hide that boxes is somewhat dangerous (a closed box is prone to accidental deletion) and show the boxes in a complex LyX document make the text not more readable/writable that a good formatted LaTeX source code with syntax highlighting.

Another source of frustration for the LyX user is when you have a layout (.layout file) for some document class that is not available (no .cls file) while you have tons of document classes in TeX Live that have not the corresponding LyX layout. Make yourself a LyX layout for some document class? A nightmare for the novice. Use only standard classes? You know ... Rather dead that plain. Instead, the LaTeX user simply can use any existing .cls file ...and that is all.

In summary, everyone think that you can drive cars without a basic background about engines ... until the car stops. Then realize that one must learn mechanics and get your hands dirty.

Therefore, IMHO, the hard but right way is start with LaTeX, at least until you are able to make some complex document like an article with tables and figures, footnotes, headers, table of contents and bibliography. Only then you can fully understand what LyX are doing for you, and what to do when things go wrong. And only then you can decide fully aware if LyX makes your work easier or harder.

-