<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ernst z&#039;n Blog &#187; celbreedte</title>
	<atom:link href="http://www.ernstblaauw.nl/tag/celbreedte/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ernstblaauw.nl</link>
	<description>Van alles en nog wat</description>
	<lastBuildDate>Thu, 08 Apr 2010 14:18:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Gekleurde achtergrond bij tabelrij in LaTeX</title>
		<link>http://www.ernstblaauw.nl/2007/12/11/gekleurde-achtergrond-bij-tabelrij-in-latex/</link>
		<comments>http://www.ernstblaauw.nl/2007/12/11/gekleurde-achtergrond-bij-tabelrij-in-latex/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 17:00:21 +0000</pubDate>
		<dc:creator>Ernst</dc:creator>
				<category><![CDATA[latex]]></category>
		<category><![CDATA[achtergrondkleur]]></category>
		<category><![CDATA[celbreedte]]></category>
		<category><![CDATA[colortbl]]></category>
		<category><![CDATA[tabel]]></category>
		<category><![CDATA[tabelbreedte]]></category>
		<category><![CDATA[tabular]]></category>
		<category><![CDATA[xcolor]]></category>
		<category><![CDATA[\rowcolor]]></category>

		<guid isPermaLink="false">http://www.ernstblaauw.nl/2007/12/11/gekleurde-achtergrond-bij-tabelrij-in-latex/</guid>
		<description><![CDATA[Als je in LaTeX een tabel een achtergrondkleurtje wilt geven, is dat meestal niet zo lastig. Soms kan het echter lastig zijn, als je breedte van je tabel wilt specificeren. Hoe los je dat dan op? Als je een standaard tabel hebt, is er niets moeilijks aan. Je voegt de packages &#8216;xcolor&#8217; (met de optie [...]]]></description>
			<content:encoded><![CDATA[<p>Als je in LaTeX een tabel een achtergrondkleurtje wilt geven, is dat meestal niet zo lastig. Soms kan het echter lastig zijn, als je breedte van je tabel wilt specificeren. Hoe los je dat dan op?<br />
<span id="more-25"></span><br />
Als je een standaard tabel hebt, is er niets moeilijks aan. Je voegt de packages &#8216;xcolor&#8217; (met de optie &#8216;table&#8217;) en  &#8216;colortbl&#8217; toe aan je preamble. Een rij in je tabel kan je dan als volgt kleuren:</p>
<blockquote>
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td>\begin{tabular}{|l l l|}<br />
\hline<br />
\rowcolor{gray!25}\textbf{Titel 1} &amp; \textbf{Titel 2}   \\ \hline \hline<br />
1e cel &amp; wat tekst \\ \hline<br />
2e regel &amp; nog wat tekst  \\ \hline<br />
\end{tabular}</td>
</tr>
<tr>
<td><a href="http://www.ernstblaauw.nl/2007/12/11/gekleurde-achtergrond-bij-tabelrij-in-latex/latex-tabel-1/" rel="attachment wp-att-35" title="LaTeX tabel 1"><img src="http://www.ernstblaauw.nl//wp-content/uploads/2007/12/simpele-tabel-1.PNG" alt="LaTeX tabel 1" /></a></td>
</tr>
</table>
</blockquote>
<h3>Breedte cel bepalen</h3>
<p>Wil je zelf de breedte bepalen van een cel, dan kan je &#8216;p{}&#8217; gebruiken; daarmee geef je aan dat in die kolom een paragraaf staat, zodat LaTeX de zinnen afbreekt waar nodig:</p>
<blockquote>
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td>\begin{tabular}{|l  <strong>p{3cm}</strong>|}<br />
\hline<br />
\rowcolor{gray!25}\textbf{Titel 1} &amp; \textbf{Titel 2}  \\ \hline \hline<br />
1e cel &amp; wat tekst  \\ \hline<br />
2e regel &amp; nog wat tekst  \\ \hline<br />
\end{tabular}</td>
</tr>
<tr>
<td><a href="http://www.ernstblaauw.nl/2007/12/11/gekleurde-achtergrond-bij-tabelrij-in-latex/latex-tabel-2/" rel="attachment wp-att-31" title="LaTeX tabel 2"><img src="http://www.ernstblaauw.nl//wp-content/uploads/2007/12/simpele-tabel-2.png" alt="LaTeX tabel 2" /></a></td>
</tr>
</table>
</blockquote>
<h3>Breedte tabel instellen</h3>
<p>Dit werkt allemaal prima. Als je nu zelf de totale breedte van de tabel wilt bepalen, moet je aan de slag met &#8216;tabular*&#8217;. Je geeft daar de breedte op, en door extra witruimte toe te voegen wordt de tabel zo wijd als nodig. Maar, &#8216;\rowcolor&#8217; gedraagt zich nu vreemd. Het kleurt de witruimtes in de tabel niet:</p>
<blockquote>
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td>\begin{<strong>tabular*</strong>}{0.5\linewidth}{|@{\extracolsep{\fill}}l p{3cm}|} \hline<br />
\rowcolor{gray!25}\textbf{Titel 1} &amp; \textbf{Titel 2}   \\ \hline \hline<br />
1e cel &amp; wat tekst  \\ \hline<br />
2e regel &amp; nog wat tekst  \\ \hline<br />
\end{tabular*}</td>
</tr>
<tr>
<td><a href="http://www.ernstblaauw.nl/2007/12/11/gekleurde-achtergrond-bij-tabelrij-in-latex/latex-tabel-3/" rel="attachment wp-att-32" title="LaTeX tabel 3"><img src="http://www.ernstblaauw.nl//wp-content/uploads/2007/12/simpele-tabel-3.png" alt="LaTeX tabel 3" /></a></td>
</tr>
</table>
</blockquote>
<p>Dit is niet zo eenvoudig op te lossen. Aangezien je de breedte van de tabel hebt gespecificeerd, kan je een gekleurde rechthoek tekenen, die precies de goede grootte heeft:</p>
<blockquote>
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td>\begin{tabular*}{0.5\linewidth}{|@{}l@{\extracolsep{\fill}}l p{3cm}|} \hline<br />
<strong>\makebox[0pt][l]{\fboxsep0pt\colorbox{gray!25}{\strut\hspace*{0.5\linewidth}}}&amp;</strong><br />
\textbf{Titel 1} &amp; \textbf{Titel 2}   \\ \hline \hline<br />
&amp;1e cel &amp; wat tekst  \\ \hline<br />
&amp;2e regel &amp; nog wat tekst  \\ \hline<br />
\end{tabular*}</td>
</tr>
<tr>
<td><a href="http://www.ernstblaauw.nl/2007/12/11/gekleurde-achtergrond-bij-tabelrij-in-latex/latex-tabel-4/" rel="attachment wp-att-33" title="LaTeX tabel 4"><img src="http://www.ernstblaauw.nl//wp-content/uploads/2007/12/simpele-tabel-4.png" alt="LaTeX tabel 4" /></a></td>
</tr>
</table>
</blockquote>
<p>Let op, dat je dus eigenlijk een extra kolom toevoegt en je nu dus alle rijen moet beginnen met een &#8216;&amp;&#8217;!</p>
<p>Hiermee is de rij van je tabel toch goed gekleurd Ã©n kan je gebruik maken van &#8216;tabular*&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ernstblaauw.nl/2007/12/11/gekleurde-achtergrond-bij-tabelrij-in-latex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

