Pedro's blog: db2, mysql, php, linux and performance


Latex longtable issue
10/01/2010, 11:37
Filed under: Latex | Tags: ,

I had a problem with a longtable in LaTeX, the margins where so much big and my table was disappearing on the right side:

Longtable issue

The code was:

\begin{longtable}{| c | c | c |}
\rowcolor[rgb]{0.52, 0.52, 0.52} \textbf{Castellano}  & \textbf{Inglés}  & \textbf{Valenciano}  \\ \hline
Artes decorativas /aplicadas    &    Applied Arts    &    Arts decoratives     \\ \hline

\end{longtable}

For fixing it, I had to write the width of every column, and LaTeX did the rest:

\begin{longtable}{| p{0.30\linewidth} | p{0.30\linewidth}  | p{0.29\linewidth}  |}
\rowcolor[rgb]{0.52, 0.52, 0.52} \textbf{Castellano}  & \textbf{Inglés}  & \textbf{Valenciano}  \\ \hline  \endfirsthead
Artes decorativas /aplicadas    &    Applied Arts    &    Arts decoratives     \\ \hline
\end{longtable}

The result:
Longtable issue
And now everything is working properly, I lost the center property but I don’t care.

If you want, you can use the \endhead, \endfoot and \endlastfoot for adding a line on the table with some text before break the line and at the begging of the new page on the continuation of the table, looks cool:

\begin{longtable}{| p{0.30\linewidth} | p{0.30\linewidth} | p{0.29\linewidth} |}
\rowcolor[rgb]{0.52, 0.52, 0.52} \textbf{Castellano} & \textbf{Inglés} & \textbf{Valenciano} \\ \hline \endfirsthead
\caption[Técnicas]{Técnicas} \label{lsttecnicas} \\ \hline
\rowcolor[rgb]{0.52, 0.52, 0.52} \textbf{Castellano} & \textbf{Inglés} & \textbf{Valenciano} \\ \hline \endfirsthead
\hline Continuación de la tabla \\ \hline \hline \endhead
\hline\hline {\scriptsize Continúa en la página siguiente} \\
\hline \endfoot
\hline\endlastfoot

    Primera línea \\ \hline
    Segunda línea \\ \hline
    ...
\end{longtable}

Cheers!



Listings code on Latex – XSLT
09/12/2009, 17:47
Filed under: Latex | Tags: , , ,

Using the package listings you can add non-formatted text as you would do with \begin{verbatim} but its main aim is to include the source code of any programming language within your document.  Wikibooks

One of the problems of this package is the poor colored syntax with some programming languages, like XML or XSLT, trying language=XML and language=XSLT, the result was… bullshit poor, I prefere to use language=HTML because it has a minimal pretty syntax  and I made some changes, the result:

\lstnewenvironment{fakeXML}[1][]{
\lstset{basicstyle=\scriptsize\sffamily,
linewidth=0.90\linewidth,
numbers=left,
stepnumber=1,
numbersep=10pt,
frame=single,
framerule=1.0pt,
backgroundcolor=\color{darkgray},
language=HTML,
identifierstyle=\color[rgb]{1,0,0},
emph={schema, element, complexType, choice, simpleType, sequence, restriction, pattern}, emphstyle=\color{red},
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.133,0.545,0.133},
stringstyle=\color[rgb]{0.627,0.126,0.941},
morekeywords={xml, ref, xs, version, targetNamespace, minOccurs, maxOccurs}
}\lstset{#1}}{}

\begin{fakeXML}
<?xml version=”1.0″?>
<xs:schema targetNamespace=…

</xs:schema>
\end{fakeXML}

It looks like:

Listings and XML

Another problem solved! 😆