# Edit LaTeX source in LyX

I recently installed LyX 2.0.1 (2011-08-31). I have the option to display the LaTeX source. I have tried to modify this source (in the LyX tab) in order to get some changes in the LyX file and the pdf output but I couldn't. I want to modify the LaTeX source directly in LyX because sometimes LyX doesn't align the tables as I want or the spaces between the lines or even the list are not in the format I want. How can I do that?

• Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Marco Daniel Oct 7 '11 at 14:17
• Where is the question? – Marco Daniel Oct 7 '11 at 14:19
• @Marco: I think/hope my edit reflects what armando wants to know. – doncherry Oct 7 '11 at 16:23
• @armando: Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. I hope you don't mind me adding a "How can I do that?" at the end of your question. – doncherry Oct 7 '11 at 16:25

If you want to edit the LaTeX source, then LyX is the wrong tool. Use one of the LaTeX editors, e.g. TeXworks, TeXmaker, aso. LyX can only edit it's own file format which of course can have some part of LaTeX code, called ERT (Evil Red Text), but that is also part of the LyX file.

You can use CTRL + L to insert latex code anywhere. That is especially useful for mathematical equations, where auto-completion works. For example, you don't have to type \alpha, you type \a, and see many suggestions for auto-complete. To delete anything, you can uses Lyx main window.

It works neat with math, but it probably does not much sense to use it for text editing. Because for usual text you will see chunks of latex code, not WYSIWYG.

• Welcome to TeX.SX! This is rather a comment than an answer to the question – user31729 Jan 6 '15 at 10:25
• Answers should not only contain pointers to figure out the solution by oneself, but should give as much of a solution as possible (partial answers are ok if the problem is hard, but then the answer should show why this is hard). Please improve your answer by giving an example (e.g., using screenshots) that shows exactly how the source code can be modified directly. – cryingshadow Jan 6 '15 at 10:47

Suppose you want to modify a formula which was entered in lyx. One possibility is to display the latex source for the formula, copy it, and paste it in some latex editor. You can then modify it with the latex editor, copy it, and paste it back in the lyx editor in math-mode.

• By math-mode you mean Ctrl+L? – Antony Hatchkins Nov 23 '16 at 10:08

It might seem to be a dirty hack, but if you edit the lyx source file directly, the changes will be reflected in PDF (I think they won't be persistent though).