Hello LaTeX users.
My problem is to copy programming code from a compiler (with the colors, spaces, and so on) into my Lyx document and KEEP the formatting (colors, etc.).
I want this output in PDF from LyX.
I've searched the Internet and found out that the writer2tex extension for LibreOffice Writer has the solution. So I copy the programming code to Writer (see link above), then exporting this text into .tex (which works fine too), open LyX and import the file as LaTeX (plain).
Now I see this:
It gives me errors of \usepackage "Option clash for package babel." and a lot of undefined colors "Undefined color `['."
I also tried to use TeXworks. It can export it to PDF and keep the format, but not inside my hand-in document (the other tab in my picture above) in LyX. It also shows me the LaTeX code and tried to copy it in LyX as Tex code, but didn't work either.
Do you have any idea of what I'm doing wrong or how I can solve this problem?
Text Formatting ⇒ Keep the Formatting for copied Text
Keep the Formatting for copied Text
Last edited by localghost on Wed Sep 19, 2012 5:13 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

Keep the Formatting for copied Text
Hi kr0w ,
Welcome to the LaTeX community!
This most probable means that you're document is loading babel twice but with a different set of options.
These are causing the errors. The
but is actually the first:
Since there nowhere is a color name
The best way to use code in a LaTeX document is by using the listings package. How you can use it with LyX I cannot tell as I am inexperienced with LyX.
Regards
Welcome to the LaTeX community!
kr0w wrote:It gives me errors of \usepackage "Option clash for package babel."
This most probable means that you're document is loading babel twice but with a different set of options.
In the red marked LaTeX code in your LyX document you can seekr0w wrote:and a lot of undefined colors "Undefined color `['."
Code: Select all
\textcolor{[}{rgb}]{0.5803922,0.11765706,0.8745098}{public}
\textcolor
command takes two or three arguments, depending on the usage.- Either
\textcolor{<colorname>}{<text to be colored>}
, for example\textcolor{red}{Attention!}
- or
\textcolor[<colormodel>]{<specs>}{<text to be colored>}
, for example\textcolor{rgb}{1,0,0}{Attention!}
Code: Select all
\textcolor[rgb]{0.5803922,0.11765706,0.8745098}{public}
Code: Select all
\textcolor{[}{rgb}% all that follows now isn't argument to \textcolor
[
defined you get these errors.The best way to use code in a LaTeX document is by using the listings package. How you can use it with LyX I cannot tell as I am inexperienced with LyX.
Regards
site moderator & package author