mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
- tex2lyx/preamble.cpp, text.cpp: add support for \textcolor fixes http://bugzilla.lyx.org/show_bug.cgi?id=2457
- box-color.tex: testfile for tex2lyx to check if colors and boxes are correctly imported git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24403 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fd56ba9b44
commit
b6eed01602
99
src/tex2lyx/box-color.tex
Normal file
99
src/tex2lyx/box-color.tex
Normal file
@ -0,0 +1,99 @@
|
||||
\documentclass[a4paper,12pt]{article}
|
||||
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[latin9]{inputenc}
|
||||
|
||||
\usepackage{amsmath}
|
||||
\usepackage{color}
|
||||
|
||||
\setlength{\parskip}{3mm}
|
||||
\setlength{\parindent}{0sp}
|
||||
\usepackage{setspace}
|
||||
\setstretch{1.2}
|
||||
|
||||
\setlength{\fboxsep}{3mm}
|
||||
|
||||
\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\section{Boxes}
|
||||
|
||||
\subsection{Frameless Boxes}
|
||||
|
||||
blabla \mbox{test} blabla
|
||||
|
||||
blabla \makebox{test} blabla
|
||||
|
||||
blabla \makebox[3cm]{test} blabla
|
||||
|
||||
blabla \makebox[3cm][l]{test} blabla
|
||||
|
||||
\begin{figure}[ht]
|
||||
\centering
|
||||
\setlength{\unitlength}{.2in}
|
||||
|
||||
\begin{picture}(8,6)
|
||||
\put(0,0){\makebox(0,0)[tr]{AAA}}
|
||||
\put(8,0){\makebox(0,0){BBB}}
|
||||
\put(1,0){\line(1,0){6}}
|
||||
\end{picture}
|
||||
|
||||
\end{figure}
|
||||
|
||||
\raisebox {8.5mm}{test}\raisebox {-6.5mm}{tset}
|
||||
|
||||
\subsection{Framed Boxes}
|
||||
|
||||
blabla \fbox{test} blabla
|
||||
|
||||
blabla \framebox[3cm]{test} blabla
|
||||
|
||||
blabla \framebox[3cm][l]{test} blabla
|
||||
|
||||
Dies ist ein Beispieltext. %
|
||||
\framebox{%
|
||||
\begin{minipage}[c][1\totalheight][s]{0.2\columnwidth}%
|
||||
\begin{center}
|
||||
Der Boxinhalt
|
||||
\par\end{center}
|
||||
|
||||
\begin{center}
|
||||
ist über die
|
||||
\par\end{center}
|
||||
|
||||
\begin{center}
|
||||
Boxhöhe
|
||||
\par\end{center}
|
||||
|
||||
\begin{center}
|
||||
gleichmäßig verteilt.
|
||||
\par\end{center}%
|
||||
\end{minipage}}
|
||||
Dies ist ein Beispieltext.
|
||||
|
||||
$\boxed{\int A=B}$
|
||||
|
||||
\section{Colors}
|
||||
|
||||
\subsection{Predefined Colors}
|
||||
|
||||
test \textcolor{blue}{blue} test \textcolor{red}{red red red} test \textcolor{green}{bla}\textcolor{magenta}{blub}
|
||||
test
|
||||
\textcolor{green}{c}%
|
||||
\textcolor{red}{o}%
|
||||
\textcolor{blue}{l}%
|
||||
\textcolor{green}{o}%
|
||||
\textcolor{red}{r}
|
||||
|
||||
\subsection{Custom Colors}
|
||||
|
||||
test \textcolor{darkgreen}{dark green} test
|
||||
|
||||
\definecolor{violet}{rgb}{0.5, 0, 1}
|
||||
|
||||
test \textcolor{violet}{violet} test
|
||||
|
||||
\end{document}
|
@ -238,6 +238,7 @@ void handle_package(string const & name, string const & opts)
|
||||
// roman fonts
|
||||
if (is_known(name, known_roman_fonts))
|
||||
h_font_roman = name;
|
||||
|
||||
if (name == "fourier") {
|
||||
h_font_roman = "utopia";
|
||||
// when font uses real small capitals
|
||||
@ -246,8 +247,10 @@ void handle_package(string const & name, string const & opts)
|
||||
}
|
||||
if (name == "mathpazo")
|
||||
h_font_roman = "palatino";
|
||||
|
||||
if (name == "mathptmx")
|
||||
h_font_roman = "times";
|
||||
|
||||
// sansserif fonts
|
||||
if (is_known(name, known_sans_fonts)) {
|
||||
h_font_sans = name;
|
||||
@ -270,6 +273,7 @@ void handle_package(string const & name, string const & opts)
|
||||
|
||||
else if (name == "amsmath" || name == "amssymb")
|
||||
h_use_amsmath = "1";
|
||||
|
||||
else if (name == "babel" && !opts.empty()) {
|
||||
// check if more than one option was used - used later for inputenc
|
||||
// in case inputenc is parsed before babel, set the encoding to auto
|
||||
@ -298,8 +302,10 @@ void handle_package(string const & name, string const & opts)
|
||||
h_quotes_language = h_language;
|
||||
}
|
||||
}
|
||||
|
||||
else if (name == "fontenc")
|
||||
; // ignore this
|
||||
|
||||
else if (name == "inputenc") {
|
||||
// only set when there is not more than one inputenc option
|
||||
// therefore check for the "," character
|
||||
@ -312,10 +318,18 @@ void handle_package(string const & name, string const & opts)
|
||||
else
|
||||
h_inputencoding = opts;
|
||||
options.clear();
|
||||
|
||||
} else if (name == "makeidx")
|
||||
; // ignore this
|
||||
|
||||
else if (name == "verbatim")
|
||||
; // ignore this
|
||||
|
||||
else if (name == "color")
|
||||
// with the following command this package is only loaded when needed for
|
||||
// undefined colors, since we only support the predefined colors
|
||||
h_preamble << "\\@ifundefined{definecolor}\n {\\usepackage{color}}{}\n";
|
||||
|
||||
else if (name == "graphicx")
|
||||
; // ignore this
|
||||
else if (is_known(name, known_languages)) {
|
||||
@ -348,6 +362,7 @@ void handle_package(string const & name, string const & opts)
|
||||
}
|
||||
} else if (name == "jurabib") {
|
||||
h_cite_engine = "jurabib";
|
||||
|
||||
} else if (options.empty())
|
||||
h_preamble << "\\usepackage{" << name << "}\n";
|
||||
else {
|
||||
|
@ -1847,6 +1847,23 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
eat_whitespace(p, os, context, false);
|
||||
}
|
||||
|
||||
else if (t.cs() == "textcolor") {
|
||||
// scheme is \textcolor{color name}{text}
|
||||
string const color = p.verbatim_item();
|
||||
// we only support the predefined colors of the color package
|
||||
if (color == "black" || color == "blue" || color == "cyan"
|
||||
|| color == "green" || color == "magenta" || color == "red"
|
||||
|| color == "white" || color == "yellow") {
|
||||
context.check_layout(os);
|
||||
os << "\n\\color " << color << "\n";
|
||||
parse_text_snippet(p, os, FLAG_ITEM, outer, context);
|
||||
context.check_layout(os);
|
||||
os << "\n\\color inherit\n";
|
||||
} else
|
||||
// for custom defined colors
|
||||
handle_ert(os, t.asInput() + "{" + color + "}", context);
|
||||
}
|
||||
|
||||
else if (t.cs() == "underbar") {
|
||||
// Do NOT handle \underline.
|
||||
// \underbar cuts through y, g, q, p etc.,
|
||||
|
Loading…
Reference in New Issue
Block a user