Add automatic color package loading for listings

The listings inset does automatically load the color package if any parameter
contains \color. As mentioned in bug #8066 tex2lyx needs to be aware of this,
so the \usepckage{color} is automatically skipped in these cases.
This commit is contained in:
Georg Baum 2012-10-18 20:41:23 +02:00
parent 75e809c023
commit 75ba5d3db5
3 changed files with 4 additions and 2 deletions

View File

@ -1037,7 +1037,7 @@ Listings
Inline:
\begin_inset listings
lstparams "language={C++}"
lstparams "language={C++},keywordstyle={\color{green}}"
inline true
status collapsed

View File

@ -181,7 +181,7 @@ parser test (escaped):\href{http://www.test.test}{a brace \} and another one \{
\section{Listings}
Inline: \lstinline[language={C++}]!int a=5;!\\
Inline: \lstinline[language={C++},keywordstyle={\color{green}}]!int a=5;!\\
Float:
\begin{lstlisting}[caption={Example Listing float},label={lst:Example-Listing},language=Python]

View File

@ -1154,6 +1154,8 @@ void parse_listings(Parser & p, ostream & os, Context & parent_context, bool in_
if (p.hasOpt()) {
string arg = p.verbatimOption();
os << "lstparams " << '"' << arg << '"' << '\n';
if (arg.find("\\color") != string::npos)
preamble.registerAutomaticallyLoadedPackage("color");
}
if (in_line)
os << "inline true\n";