<?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>Matthias Pospiech &#187; LaTeX</title>
	<atom:link href="http://www.matthiaspospiech.de/blog/category/latex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matthiaspospiech.de</link>
	<description></description>
	<lastBuildDate>Mon, 31 May 2010 19:37:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Installation of Fonts in Miktex</title>
		<link>http://www.matthiaspospiech.de/blog/2008/10/07/installation-of-fonts-in-miktex/</link>
		<comments>http://www.matthiaspospiech.de/blog/2008/10/07/installation-of-fonts-in-miktex/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 09:31:42 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[Miktex]]></category>

		<guid isPermaLink="false">http://www.matthiaspospiech.de/blog/2008/10/07/installation-of-fonts-in-miktex/</guid>
		<description><![CDATA[I have several Type1 fonts which need to be installed such that LaTeX knows about them. To achive this under Miktex you have to follow these steps:

	Setup you localtexmf tree with the fonts or copy your localtexmf tree from a different installation into the corresponding Miktex directory.
	Run initexmf --edit-config-file updmap. That will open an editor.
	Insert [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/04/03/installation-of-opensuse-102/' rel='bookmark' title='Permanent Link: Installation of openSuse 10.2'>Installation of openSuse 10.2</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/03/11/grub-installation/' rel='bookmark' title='Permanent Link: Grub installation'>Grub installation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I have several Type1 fonts which need to be installed such that LaTeX knows about them. To achive this under Miktex you have to follow these steps:</p>
<ol>
	<li>Setup you localtexmf tree with the fonts or copy your localtexmf tree from a different installation into the corresponding Miktex directory.</li>
	<li>Run <code>initexmf --edit-config-file updmap</code>. That will open an editor.</li>
	<li>Insert in that file all map files in the following form:<pre><code>Map xyz.map</code></pre> Save the file afterwards.</li>
	<li>Run <code>initexmf --mkmaps</code> to rebuild the font map files.</li>
</ol>








<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/04/03/installation-of-opensuse-102/' rel='bookmark' title='Permanent Link: Installation of openSuse 10.2'>Installation of openSuse 10.2</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/03/11/grub-installation/' rel='bookmark' title='Permanent Link: Grub installation'>Grub installation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2008/10/07/installation-of-fonts-in-miktex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Alternatives Syntaxhighlighting</title>
		<link>http://www.matthiaspospiech.de/blog/2008/08/04/alternatives-syntaxhighlighting/</link>
		<comments>http://www.matthiaspospiech.de/blog/2008/08/04/alternatives-syntaxhighlighting/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 19:40:27 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Geshi]]></category>

		<guid isPermaLink="false">http://www.matthiaspospiech.de/blog/2008/08/04/alternatives-syntaxhighlighting/</guid>
		<description><![CDATA[Hier das neue Syntaxhighlighting von LaTeX in geshi


% Beispieldokument
\documentclass[a4paper, 11pt,german]{scrartcl}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
&#160;
\makeatletter
% Check for 'draft' mode - commands.
\newcommand{\IfDraft}[1]{\ifx\@draft\@undefined \else #1 \fi}
\makeatother
&#160;
\begin{document}
	$ a = b + c $
	\begin{equation}
		a = b + c
	\end{equation}
	\begin{figure}
		\includegraphics{Bild.png}
	\end{figure}
	\section{Einleitung}
	Dies ist ein beliebig langer Satz ohne konkreten Hintergrund.
	\cite[S. 22]{Mustermann}
	\begin{table}[tb]
		\centering
		\begin{tabular}{ll}
			links Spalte &#38; rechte Spalte \\
		\end{tabular}
		\caption[Eine Testtabelle]{Testtabelle}
		\label{tab:test}
	\end{table}
	Besondere Befehle: \_, \&#38;, \% sollten auch funktionieren.
	\subsection*{Erl&#228;uterung}
	Verschachtelte Befehle: 
	% Command for [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/06/25/syntaxhighlighting-von-latex-in-webseiten/' rel='bookmark' title='Permanent Link: Syntaxhighlighting von LaTeX in Webseiten'>Syntaxhighlighting von LaTeX in Webseiten</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/' rel='bookmark' title='Permanent Link: Definition von Makros und Umgebungen'>Definition von Makros und Umgebungen</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hier das neue Syntaxhighlighting von LaTeX in geshi</p>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% Beispieldokument</span>
<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">documentclass</span></span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">a4paper, 11pt,german</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">scrartcl</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">lmodern</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">textcomp</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">german</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">babel</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">T1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">fontenc</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">latin1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">inputenc</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">graphicx</span><span style="color: #E02020; ">}</span>
&nbsp;
<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">makeatletter</span></span>
<span style="color: #2C922C; font-style: italic;">% Check for 'draft' mode - commands.</span>
<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\IfDraft</span></span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\ifx</span><span style="color: #E00000; font-weight: normal;">\@draft</span><span style="color: #E00000; font-weight: normal;">\@undefined</span> <span style="color: #800000; font-weight: normal;">\else</span> #1 <span style="color: #800000; font-weight: normal;">\fi</span></span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">makeatother</span></span>
&nbsp;
<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span>
	<span style="color: #8020E0; font-weight: normal;">$ a = b + c $</span>
	<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">equation</span></span><span style="color: #E02020; ">}</span><span style="color: #8020E0; font-weight: normal;">
		a = b + c
	</span><span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">equation</span></span><span style="color: #E02020; ">}</span>
	<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">figure</span></span><span style="color: #E02020; ">}</span>
		<span style="color: #800000; font-weight: normal;">\includegraphics</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">Bild.png</span><span style="color: #E02020; ">}</span>
	<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">figure</span></span><span style="color: #E02020; ">}</span>
	<span style="color: #800000; font-weight: normal;">\section</span><span style="color: #E02020; ">{</span><span style="color: #00008B; font-weight: bold;">Einleitung</span><span style="color: #E02020; ">}</span>
	Dies ist ein beliebig langer Satz ohne konkreten Hintergrund.
	<span style="color: #800000; font-weight: normal;">\cite</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">S. 22</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">Mustermann</span><span style="color: #E02020; ">}</span>
	<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">table</span></span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">tb</span><span style="color: #E02020; ">]</span>
		<span style="color: #800000; font-weight: normal;">\centering</span>
		<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">tabular</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">ll</span><span style="color: #E02020; ">}</span>
			links Spalte <span style="color: #E02020; ">&amp;</span> rechte Spalte <span style="color: #E02020; ">\\</span>
		<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">tabular</span></span><span style="color: #E02020; ">}</span>
		<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">caption</span></span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">Eine Testtabelle</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">Testtabelle</span><span style="color: #E02020; ">}</span>
		<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">label</span></span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">tab:test</span><span style="color: #E02020; ">}</span>
	<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">table</span></span><span style="color: #E02020; ">}</span>
	Besondere Befehle: <span style="color: #800000; font-weight: normal;">\_</span>, <span style="color: #800000; font-weight: normal;">\&amp;</span>, <span style="color: #800000; font-weight: normal;">\%</span> sollten auch funktionieren.
	<span style="color: #800000; font-weight: normal;">\subsection*</span><span style="color: #E02020; ">{</span><span style="color: #00008B; font-weight: bold;">Erläuterung</span><span style="color: #E02020; ">}</span>
	Verschachtelte Befehle: 
	<span style="color: #2C922C; font-style: italic;">% Command for margin text with usefull style</span>
	<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\marginlabel</span></span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">
		<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">mbox</span></span><span style="color: #E02020; ">{</span></span><span style="color: #2020C0; font-weight: normal;">}<span style="color: #800000; font-weight: normal;">\marginline</span><span style="color: #E02020; ">{</span><span style="color: #800000; font-weight: normal;">\hspace</span><span style="color: #E02020; ">{</span>0pt</span><span style="color: #E02020; ">}</span><span style="color: #800000; font-weight: normal;">\footnotesize</span><span style="color: #800000; font-weight: normal;">\sffamily</span> #1<span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
	<span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span></pre></div></div>





<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/06/25/syntaxhighlighting-von-latex-in-webseiten/' rel='bookmark' title='Permanent Link: Syntaxhighlighting von LaTeX in Webseiten'>Syntaxhighlighting von LaTeX in Webseiten</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/' rel='bookmark' title='Permanent Link: Definition von Makros und Umgebungen'>Definition von Makros und Umgebungen</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2008/08/04/alternatives-syntaxhighlighting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial zu \expandafter</title>
		<link>http://www.matthiaspospiech.de/blog/2008/04/18/tutorial-zu-expandafter/</link>
		<comments>http://www.matthiaspospiech.de/blog/2008/04/18/tutorial-zu-expandafter/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 21:53:00 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://www.matthiaspospiech.de/blog/2008/04/18/tutorial-zu-expandafter/</guid>
		<description><![CDATA[Folgendes PDF konnten ich dazu im Internet finden:
tb20bechtolsheim.pdf. 

Es ist zwar uralt (von 1988) aber da sich TeX nicht ge&#228;ndert hat sollte der Inhalt weiterhin g&#252;ltig sein.

Hier zwei Beispiele daraus. Dazu bezeichne ich im Folgenden die Befehle mit \a\b und expandierte Werte mit (a), (b) sowie zwischengespeicherte Werte mit S(a), S(b) usw. 
Die \expandafter bezeichne [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/05/31/existenz-von-paketen-pruefen/' rel='bookmark' title='Permanent Link: Existenz von Paketen pr&#252;fen'>Existenz von Paketen pr&#252;fen</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/' rel='bookmark' title='Permanent Link: LaTeX Variablen, If Abfragen und Schleifen'>LaTeX Variablen, If Abfragen und Schleifen</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/' rel='bookmark' title='Permanent Link: Definition von Makros und Umgebungen'>Definition von Makros und Umgebungen</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[Folgendes PDF konnten ich dazu im Internet finden:
<a href="http://www.tug.org/TUGboat/Articles/tb09-1/tb20bechtolsheim.pdf" class="lipdf">tb20bechtolsheim.pdf</a>. 

Es ist zwar uralt (von 1988) aber da sich TeX nicht ge&#228;ndert hat sollte der Inhalt weiterhin g&#252;ltig sein.

Hier zwei Beispiele daraus. Dazu bezeichne ich im Folgenden die Befehle mit \a\b und expandierte Werte mit (a), (b) sowie zwischengespeicherte Werte mit S(a), S(b) usw. <br />
Die \expandafter bezeichne und nummeriere ich mit \ex1 \exp2.

Die Beispiel demonstrieren jeweils ein umgekehrte Expansion der Befehle
<ul>
	<li>Reihenfolge b, a


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\ex</span>1<span style="color: #800000; font-weight: normal;">\a</span><span style="color: #800000; font-weight: normal;">\b</span>
S(<span style="color: #800000; font-weight: normal;">\a</span>) (b)
<span style="color: #800000; font-weight: normal;">\a</span> (b)
(a) (b)</pre></div></div>



</li>
	<li>Reihenfolge c, b, a


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\ex</span>1<span style="color: #800000; font-weight: normal;">\ex</span>2<span style="color: #800000; font-weight: normal;">\ex</span>3<span style="color: #800000; font-weight: normal;">\a</span><span style="color: #800000; font-weight: normal;">\ex</span>4<span style="color: #800000; font-weight: normal;">\b</span><span style="color: #800000; font-weight: normal;">\c</span>
S(<span style="color: #800000; font-weight: normal;">\ex</span>2)<span style="color: #800000; font-weight: normal;">\ex</span>3<span style="color: #800000; font-weight: normal;">\a</span><span style="color: #800000; font-weight: normal;">\ex</span>4<span style="color: #800000; font-weight: normal;">\b</span><span style="color: #800000; font-weight: normal;">\c</span>
S(<span style="color: #800000; font-weight: normal;">\ex</span>2)S(<span style="color: #800000; font-weight: normal;">\a</span>)<span style="color: #800000; font-weight: normal;">\ex</span>4<span style="color: #800000; font-weight: normal;">\b</span><span style="color: #800000; font-weight: normal;">\c</span>
S(<span style="color: #800000; font-weight: normal;">\ex</span>2)S(<span style="color: #800000; font-weight: normal;">\a</span>)S(<span style="color: #800000; font-weight: normal;">\b</span>)<span style="color: #800000; font-weight: normal;">\c</span>
S(<span style="color: #800000; font-weight: normal;">\ex</span>2)S(<span style="color: #800000; font-weight: normal;">\a</span>)S(<span style="color: #800000; font-weight: normal;">\b</span>)(c)
<span style="color: #800000; font-weight: normal;">\ex</span>2<span style="color: #800000; font-weight: normal;">\a</span><span style="color: #800000; font-weight: normal;">\b</span>(c)
S(<span style="color: #800000; font-weight: normal;">\a</span>)<span style="color: #800000; font-weight: normal;">\b</span>(c)
S(<span style="color: #800000; font-weight: normal;">\a</span>)(b)(c)
<span style="color: #800000; font-weight: normal;">\a</span>(b)(c)
(a)(b)(c)</pre></div></div>



</li>
</ul>




<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/05/31/existenz-von-paketen-pruefen/' rel='bookmark' title='Permanent Link: Existenz von Paketen pr&#252;fen'>Existenz von Paketen pr&#252;fen</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/' rel='bookmark' title='Permanent Link: LaTeX Variablen, If Abfragen und Schleifen'>LaTeX Variablen, If Abfragen und Schleifen</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/' rel='bookmark' title='Permanent Link: Definition von Makros und Umgebungen'>Definition von Makros und Umgebungen</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2008/04/18/tutorial-zu-expandafter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Definition von Makros und Umgebungen</title>
		<link>http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/</link>
		<comments>http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 20:58:35 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-markos-und-umgebungen/</guid>
		<description><![CDATA[LaTeX kennt Befehlen (commands) und Umgebungen (environments). Der Unterschied ist das ein Befehl direkt abgearbeitet wird wohingegen eine Umgebung zu Beginn und zum Ende der Umgebung Code ausf&#252;hrt. F&#252;r ausf&#252;hrliche Beispiele zur Nutzung von selbstdefinierten Befehl und Umgebungen bitte ich weitere LaTeX Literatur zu Rate zu ziehen. Hier werde ich nur auf die grunds&#228;tzliche Syntax [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2008/08/04/alternatives-syntaxhighlighting/' rel='bookmark' title='Permanent Link: Alternatives Syntaxhighlighting'>Alternatives Syntaxhighlighting</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/' rel='bookmark' title='Permanent Link: LaTeX Variablen, If Abfragen und Schleifen'>LaTeX Variablen, If Abfragen und Schleifen</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/06/25/syntaxhighlighting-von-latex-in-webseiten/' rel='bookmark' title='Permanent Link: Syntaxhighlighting von LaTeX in Webseiten'>Syntaxhighlighting von LaTeX in Webseiten</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[LaTeX kennt Befehlen (commands) und Umgebungen (environments). Der Unterschied ist das ein Befehl direkt abgearbeitet wird wohingegen eine Umgebung zu Beginn und zum Ende der Umgebung Code ausf&#252;hrt. F&#252;r ausf&#252;hrliche Beispiele zur Nutzung von selbstdefinierten Befehl und Umgebungen bitte ich weitere LaTeX Literatur zu Rate zu ziehen. Hier werde ich nur auf die grunds&#228;tzliche Syntax eingehen.

<a id="toc"></a><ol class="toc"><li><a href="http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#toc-neue-befehle" class="liinternal">Neue Befehle</a><ol><li><a href="http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#toc-lange-und-kurze-befehle" class="liinternal">Lange und kurze Befehle</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#toc-optionale-argumente" class="liinternal">Optionale Argumente</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#toc-mehrfache-optionale-argumente" class="liinternal">Mehrfache optionale Argumente</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#toc-verschachtelte-befehle" class="liinternal">Verschachtelte Befehle</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#toc-befehle-mit" class="liinternal">Befehle mit *</a></li></ol></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#toc-umgebungen" class="liinternal">Umgebungen</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/#toc-protect-fragile-und-robust" class="liinternal">Protect, Fragile und Robust</a></li></ol>

<span id="more-174"></span>
<h3 id="toc-neue-befehle">Neue Befehle</h3>

Ein neuer Befehl wird definiert &#252;ber


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% \newcommand{cmd}[narg]{command definition}</span>
<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\figureref</span></span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">(Abbildung <span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">ref</span></span><span style="color: #E02020; ">{</span>#1</span><span style="color: #E02020; ">}</span>)<span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span></pre></div></div>



<p>Dabei sind bis zu 9 Argumente (narg) m&#246;glich. Diese werden abgerufen &#252;ber #1, &#8230;, #9. </p>

<p>Wie man mehr als 9 Argumente &#252;begeben kann ist in der englischen FAQ erkl&#228;rt:<a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=moren9" class="liexternal">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=moren9</a>. Eine solche Anzahl von Argumenten ist jedoch nicht zu empfehlen. Besser ist es eine key=value Syntax zu verwenden.</p>



<p>Ist ein Befehl schon definiert l&#246;st ein <code>\newcommand</code> einen Fehler aus.</p>

<p>zur Definition gibt es noch weitere Befehle, jeweils mit der gleichen Syntax:</p>
<ul>
	<li><code>\renewcommand</code>: definiert ein bestehenden Befehl um. L&#246;st einen Fehler aus falls der Befehl noch nicht exisiter.</li>
	<li><code>\providecommand</code>: definiert einen Befehl unabh&#228;ngig davon ob er schon existierte oder nicht.</li>
	<li><code>\DeclareRobustCommand</code>: wie <code>\newcommand</code>, definiert allerdings einen<em><a href="#protect" class="liinternal">robusten</a></em> Befehl.</li>
</ul>

<h4 id="toc-lange-und-kurze-befehle">Lange und kurze Befehle</h4>
<p>Lange Befehle, dass sind alle die mit den vorgestellten Befehle <code>\newcommand</code>, <code>\renewcommand</code>, <code>\providecommand</code> usw. erzeugt werden erlauben Paragraphenumbr&#252;che in den Argumenten. </p>

Es gibt auch alle Befehle mit einem *


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommand*</span>
<span style="color: #800000; font-weight: normal;">\renewcommand*</span>
<span style="color: #800000; font-weight: normal;">\providecommand*</span>
...</pre></div></div>



<p>die dann <em>kurze</em> Befehle erzeugen, die dann keine Paragraphenumbr&#252;che in den Argumenten erlauben.</p>

<p>Intern sind die langen Befehl als <code>\long\def</code> definiert und die kurzen nur als <code>\def</code></p>

<h4 id="toc-optionale-argumente">Optionale Argumente</h4>
Die Syntax f&#252;r einen Befehl mit optionalem Argument ist wie folgt


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">cmd</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">narg</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">default</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">command definition</span><span style="color: #E02020; ">}</span></pre></div></div>



<p>In diesem Fall hat das Optionale Argument die Nummer #1 und wird durch den default Wert ersetzt wenn der optionale Parameter nicht genutzt wird.</p>

Im Falle von


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\foobar</span></span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">1</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">2</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">#1</span><span style="color: #E02020; ">}</span></pre></div></div>



gibt es nur ein optionales Argument. Die Ausgabe ist also standardm&#228;&#223;ig &#8220;2&#8243;, es sein denn man schreibt <code>\foobar[3]</code> was dann &#8220;3&#8243; ausgibt.

<h4 id="toc-mehrfache-optionale-argumente">Mehrfache optionale Argumente</h4>
F&#252;r die L&#246;sung gibt es mehrere Pakete. Zum einen das <a href="http://www.ctan.org/tex-archive/macros/latex/contrib/sauerj/optparams.pdf" class="lipdf">optparams</a> Paket welches die folgende Syntax bietet


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\long</span><span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">def</span></span><span style="color: #800000; font-weight: normal;">\test</span>@<span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">#1</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">#2</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">#3</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">#4</span><span style="color: #E02020; ">]{</span><span style="color: #2C922C; font-style: italic;">%</span>
	(#1) (#2) (#3) (#4)
<span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\test</span></span><span style="color: #E02020; ">}{</span><span style="color: #2C922C; font-style: italic;">%</span>
	<span style="color: #800000; font-weight: normal;">\optparams</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\test</span>@</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">[<span style="color: #C08020; font-weight: normal;">one</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">two</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">three</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">four</span><span style="color: #E02020; ">]</span></span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}</span></pre></div></div>



Hiernach gibt es bis zu 4 optionale Parameter, so dass sich folgende Ausgaben ergeben:


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\test</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">this</span><span style="color: #E02020; ">]</span> <span style="color: #2C922C; font-style: italic;">% ergibt &quot;(this) (two) (three) (four)&quot;</span>
<span style="color: #800000; font-weight: normal;">\test</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">this</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">is</span><span style="color: #E02020; ">]</span> <span style="color: #2C922C; font-style: italic;">% ergibt  &quot;(this) (is) (three) (four)&quot;</span>
<span style="color: #800000; font-weight: normal;">\test</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">this</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">is</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">a</span><span style="color: #E02020; ">]</span><span style="color: #2C922C; font-style: italic;">% ergibt &quot;(this) (is) (a) (four)&quot;</span>
<span style="color: #800000; font-weight: normal;">\test</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">this</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">is</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">a</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">test</span><span style="color: #E02020; ">]</span><span style="color: #2C922C; font-style: italic;">% ergibt  &quot;(this) (is) (a) (test)&quot;</span></pre></div></div>



Ein nichtoptionales Argument wird dann wie folgt definiert


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\long</span><span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">def</span></span><span style="color: #800000; font-weight: normal;">\test</span>@<span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">#1</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">#2</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">#3</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">#4</span><span style="color: #E02020; ">]</span>#5<span style="color: #E02020; ">{</span><span style="color: #2C922C; font-style: italic;">%</span>
	(#1) (#2) (#3) (#4) #5
<span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\test</span></span><span style="color: #E02020; ">}{</span><span style="color: #2C922C; font-style: italic;">%</span>
	<span style="color: #800000; font-weight: normal;">\optparams</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\test</span>@</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">[<span style="color: #C08020; font-weight: normal;">one</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">two</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">three</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">four</span><span style="color: #E02020; ">]</span></span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}</span></pre></div></div>



<p>Allerdings muss bei dieser Methode der erste Befehl &#252;ber ein \def definiert werden da ein \newcommand diese Syntax nicht versteht.</p>

<p>Zum Anderen gibt es das wesentlich m&#228;chtigere Paket <a href="http://ftp.gwdg.de/pub/ctan/macros/latex/contrib/xargs/xargs.pdf" class="lipdf">xargs</a> welches eine sehr flexible L&#246;sung bietet.</p>
<p>In diesem Paket werden die Befehle</p>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommandx</span>
<span style="color: #800000; font-weight: normal;">\renewcommandx</span>
<span style="color: #800000; font-weight: normal;">\providecommandx</span>
<span style="color: #800000; font-weight: normal;">\DeclareRobustCommandx</span>
<span style="color: #800000; font-weight: normal;">\CheckCommandx</span>
<span style="color: #800000; font-weight: normal;">\newenvironmentx</span>
<span style="color: #800000; font-weight: normal;">\renewenvironmentx</span></pre></div></div>



<p>
definiert, welche sich durch die vordefiniertem jeweils durch das angehangene x unterscheiden und eine etwas andere Syntax bieten:</p>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommandx*</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">command</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">number</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">list</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">definition</span><span style="color: #E02020; ">}</span>
<span style="color: #2C922C; font-style: italic;">% zum Vergleich</span>
<span style="color: #800000; font-weight: normal;">\newcommand*</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">command</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">number</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">definition</span><span style="color: #E02020; ">}</span></pre></div></div>



<p>Die Definition eines Befehls unterscheidet sich somit in der Definition von <em>list</em>. Das folgende Beispiel definiert zwei optionale Argumente</p>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommandx*</span><span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">3</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">1=1, 3=n</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">(#2_{#1</span><span style="color: #E02020; ">}</span>,<span style="color: #800000; font-weight: normal;">\ldots</span>,#2_<span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">#3</span><span style="color: #E02020; ">}</span>)<span style="color: #E02020; ">}</span>
<span style="color: #8020E0; font-weight: normal;">$<span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">x</span><span style="color: #E02020; ">}</span>$</span> <span style="color: #2C922C; font-style: italic;">% (x1, . . . , xn)</span>
<span style="color: #8020E0; font-weight: normal;">$<span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">0</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">y</span><span style="color: #E02020; ">}</span>$</span> <span style="color: #2C922C; font-style: italic;">% (y0, . . . , yn)</span>
<span style="color: #8020E0; font-weight: normal;">$<span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">z</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">m</span><span style="color: #E02020; ">]</span>$</span> <span style="color: #2C922C; font-style: italic;">% (z1, . . . , zm)</span>
<span style="color: #8020E0; font-weight: normal;">$<span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">0</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">t</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">m</span><span style="color: #E02020; ">]</span>$</span> <span style="color: #2C922C; font-style: italic;">% (t0, . . . , tm)</span></pre></div></div>



<p>Der &#8216;value&#8217; Wert bei der Liste gibt dabei den Standardwert an.</p>

<p>Um ein optionales Argument zu &#252;bergehen, also nicht anzugeben, aber das darauffolgende anzugeben muss man der Liste den Wert &#8220;usedefault&#8221; hinzuf&#252;gen. Das Beispiel sieht dann wie folgt aus</p>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommandx*</span><span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">3</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">2=1,3=n,usedefault</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">(#2_{#1</span><span style="color: #E02020; ">}</span>,<span style="color: #800000; font-weight: normal;">\ldots</span>,#2_<span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">#3</span><span style="color: #E02020; ">}</span>)<span style="color: #E02020; ">}</span>
<span style="color: #8020E0; font-weight: normal;">$<span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">x</span><span style="color: #E02020; ">}</span>$</span> <span style="color: #2C922C; font-style: italic;">% (1x, . . . , 1n)</span>
<span style="color: #8020E0; font-weight: normal;">$<span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">y</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">0</span><span style="color: #E02020; ">]</span>$</span> <span style="color: #2C922C; font-style: italic;">% (0y, . . . , 0n)</span>
<span style="color: #8020E0; font-weight: normal;">$<span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">z</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">][m</span><span style="color: #E02020; ">]</span>$</span> <span style="color: #2C922C; font-style: italic;">% (1z, . . . , 1m)</span>
<span style="color: #8020E0; font-weight: normal;">$<span style="color: #800000; font-weight: normal;">\coord</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">t</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">0</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">m</span><span style="color: #E02020; ">]</span>$</span> <span style="color: #2C922C; font-style: italic;">% (0t, . . . , 0m)</span></pre></div></div>



F&#252;r weitere M&#246;glichkeiten und potenzielle Probleme bitte die Dokumentation des Paketes zu Rate ziehen.


<h4 id="toc-verschachtelte-befehle">Verschachtelte Befehle</h4>
M&#246;chte man einen Befehl definieren, der einen weiteren Befehl umdefiniert ben&#246;tigt man je nach Tiefer der Verschachtelung vorgestellte Raouten (#). Hier ein Beispiel:


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #800000; font-weight: normal;">\TextZwischenAnfangUndEnde</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">Anfang <span style="color: #800000; font-weight: normal;">\ldots</span> #1 <span style="color: #800000; font-weight: normal;">\ldots</span> Ende</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #800000; font-weight: normal;">\NeuerAnfangUndEnde</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">2</span><span style="color: #E02020; ">]{</span><span style="color: #2C922C; font-style: italic;">%</span>
   <span style="color: #800000; font-weight: normal;">\renewcommand</span><span style="color: #800000; font-weight: normal;">\TextZwischenAnfangUndEnde</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">#1 <span style="color: #800000; font-weight: normal;">\ldots</span> ##1 <span style="color: #800000; font-weight: normal;">\ldots</span> #2</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}</span></pre></div></div>




<p>Mit der Voreingestellten Definition von <code>\TextZwischenAnfangUndEnde</code> erh&#228;lt man dann die Ausgabe</p>
<img src='/latexrender/pictures/a7f2d8cf52b26ac248185f68b240a30d.png' title='\newcommand\TextZwischenAnfangUndEnde[1]{Anfang \ldots #1 \ldots Ende}\TextZwischenAnfangUndEnde{Das Maerchen}' alt='\newcommand\TextZwischenAnfangUndEnde[1]{Anfang \ldots #1 \ldots Ende}\TextZwischenAnfangUndEnde{Das Maerchen}' align=absmiddle>

<p>Benutzt man nun den Befehl zum Umdefinieren</p>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\NeuerAnfangUndEnde</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">Es war einmal</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">Sie lebten gluecklich bis an ihr Lebensende</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\TextZwischenAnfangUndEnde</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">Das Maerchen</span><span style="color: #E02020; ">}</span></pre></div></div>



<p>so erh&#228;lt man</p>
<img src='/latexrender/pictures/a44defad7d6dbfe1bef434b1c41754cc.png' title='\newcommand\TextZwischenAnfangUndEnde[1]{Anfang \ldots #1 \ldots Ende}\newcommand\NeuerAnfangUndEnde[2]{   \renewcommand\TextZwischenAnfangUndEnde[1]{#1 \ldots ##1 \ldots #2}}\NeuerAnfangUndEnde{Es war einmal}{Sie lebten gluecklich bis an ihr Lebensende}\TextZwischenAnfangUndEnde{Das Maerchen}' alt='\newcommand\TextZwischenAnfangUndEnde[1]{Anfang \ldots #1 \ldots Ende}\newcommand\NeuerAnfangUndEnde[2]{   \renewcommand\TextZwischenAnfangUndEnde[1]{#1 \ldots ##1 \ldots #2}}\NeuerAnfangUndEnde{Es war einmal}{Sie lebten gluecklich bis an ihr Lebensende}\TextZwischenAnfangUndEnde{Das Maerchen}' align=absmiddle>

<h4 id="toc-befehle-mit">Befehle mit *</h4>
Vielleicht nicht die optimale, aber eine M&#246;glichkeit diesen Unterschied abzufangen bietet der Befehl <code>\@ifnextchar</code> mit der folgenden Notation


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\fancy</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #E00000; font-weight: normal;">\@ifnextchar*</span><span style="color: #E02020; ">{</span>Befehl mit *</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">Befehl ohne *</span><span style="color: #E02020; ">}</span> sonstiges<span style="color: #E02020; ">}</span></pre></div></div>




<h3 id="toc-umgebungen">Umgebungen</h3>
Umgebungen werden definiert &#252;ber


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newenvironment</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">cmd</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">narg</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">begin definition</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">end definition</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\renewenvironment</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">cmd</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">narg</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">begin definition</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">end definition</span><span style="color: #E02020; ">}</span>
<span style="color: #2C922C; font-style: italic;">% Erste Argument optional</span>
<span style="color: #800000; font-weight: normal;">\newenvironment</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">cmd</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">narg</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">optional</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">begin definition</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">end definition</span><span style="color: #E02020; ">}</span></pre></div></div>




M&#246;chte man in der Anfangs oder Ende Sequenz weitere Umgebungen einbringen so kann man diese nicht &#252;ber <code>\begin{<env>}</code> und <code>\end{<env>}</code> definieren. Stattdessen ben&#246;tigt man die &#228;quivalenten normalen Befehle. Hier ein Beispiel


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% \newenvironment{myquote}[1]{\small\begin{quote}}{\end{quote}} % funktioniert nicht!</span>
<span style="color: #800000; font-weight: normal;">\newenvironment</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">myquote</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\small</span><span style="color: #800000; font-weight: normal;">\quote</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\endquote</span></span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">% funktioniert</span></pre></div></div>




<a name="protect"></a>
<h3 id="toc-protect-fragile-und-robust">Protect, Fragile und Robust</h3>
Angeleht an einen Text aus der <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=protect" class="liexternal">englische FAQ</a>:

LaTeX definiert Befehle deren Daten sp&#228;ter nocheinmal eingelesen werden. Diese Daten k&#246;nnen dann Argumetne von anderen Befehlen sein. Dies kann z.B. vorkommen bei Inhaltsverzeichnissen die aus aux Dateien wieder eingelesen werden und Daten die in den Kopf und Fusszeilen landen.

Diese Befehle werden bei ihrer Ausf&#252;hrung und damit dem Speichern der Werte direkt expandiert. Manchmal erzeugt das einen Fehler wenn die Daten sp&#228;ter nochmal eingelesen werden. Dies kann verhindert werden indem man ein <code>\protect</code> vor einen Befehl stellt:


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\protect</span><span style="color: #800000; font-weight: normal;">\somecommand</span></pre></div></div>



In diesem Fall wird \somecommand nicht expandiert.

<p><em>Fragile Befehle</em> sind dann solche die in ung&#252;ltigem TeX Code beim Speichern resultieren, wohingegen <em>Robuste Befehle</em> in g&#252;ltigen Code beim Speichern expandieren. </p>



<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2008/08/04/alternatives-syntaxhighlighting/' rel='bookmark' title='Permanent Link: Alternatives Syntaxhighlighting'>Alternatives Syntaxhighlighting</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/' rel='bookmark' title='Permanent Link: LaTeX Variablen, If Abfragen und Schleifen'>LaTeX Variablen, If Abfragen und Schleifen</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/06/25/syntaxhighlighting-von-latex-in-webseiten/' rel='bookmark' title='Permanent Link: Syntaxhighlighting von LaTeX in Webseiten'>Syntaxhighlighting von LaTeX in Webseiten</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2008/04/16/definition-von-makros-und-umgebungen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX Variablen, If Abfragen und Schleifen</title>
		<link>http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/</link>
		<comments>http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 20:33:35 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://www.matthiaspospiech.de/blog/2008/04/13/latex-klassen-and-packet-programming/</guid>
		<description><![CDATA[Programmieren in TeX / LaTeXVariablen von TeX / LaTeXZ&#228;hlervariablen (counter)L&#228;ngenvariablen (length)Wahrheitswerte (boolean)Rechnen innerhalb von TeXIf Abfrage\ifcase AnweisungTeX FunktionenLaTeX FunktionenSchleifen\whiledo (nur LaTex)\loop (TeX)For Schleife (LaTeX)

Programmieren in TeX / LaTeX

Eine umfassende Dokumentation zur Programmierung von LaTeX Klassen und Paketen gibt es leider nicht. In den Anf&#228;ngen kommt man zwar mit dem LaTeX Begleiter und dem clsguide.pdf in [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2008/07/20/bbclone-in-mediawiki/' rel='bookmark' title='Permanent Link: bbclone in mediawiki'>bbclone in mediawiki</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/' rel='bookmark' title='Permanent Link: LaTeX Wiki'>LaTeX Wiki</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/05/31/existenz-von-paketen-pruefen/' rel='bookmark' title='Permanent Link: Existenz von Paketen pr&#252;fen'>Existenz von Paketen pr&#252;fen</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<a id="toc"></a><ol class="toc"><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-programmieren-in-tex-latex" class="liinternal">Programmieren in TeX / LaTeX</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-variablen-von-tex-latex" class="liinternal">Variablen von TeX / LaTeX</a><ol><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-zahlervariablen-counter" class="liinternal">Z&#228;hlervariablen (counter)</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-langenvariablen-length" class="liinternal">L&#228;ngenvariablen (length)</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-wahrheitswerte-boolean" class="liinternal">Wahrheitswerte (boolean)</a></li></ol></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-rechnen-innerhalb-von-tex" class="liinternal">Rechnen innerhalb von TeX</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-if-abfrage" class="liinternal">If Abfrage</a><ol><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-ifcase-anweisung" class="liinternal"><code>\ifcase</code> Anweisung</a></li></ol></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-tex-funktionen" class="liinternal">TeX Funktionen</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-latex-funktionen" class="liinternal">LaTeX Funktionen</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-schleifen" class="liinternal">Schleifen</a><ol><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-whiledo-nur-latex" class="liinternal">\whiledo (nur LaTex)</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-loop-tex" class="liinternal">\loop (TeX)</a></li><li><a href="http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/#toc-for-schleife-latex" class="liinternal">For Schleife (LaTeX)</a></li></ol></li></ol>

<h3 id="toc-programmieren-in-tex-latex">Programmieren in TeX / LaTeX</h3>

<p>Eine umfassende Dokumentation zur Programmierung von LaTeX Klassen und Paketen gibt es leider nicht. In den Anf&#228;ngen kommt man zwar mit dem <em>LaTeX Begleiter</em> und dem <em>clsguide.pdf</em> in das Thema hinein, hat dann aber nicht zum Anschlie&#223;en. H&#228;ufig wird man bei dem Thema auf das TeXBook verwiesen welches TeX und PlainTeX in aller Ausf&#252;hrlichkeit erkl&#228;rt aber ganz offensichtlich alle LaTeX Befehle ausl&#228;sst die einem die Programmierung erheblich vereinfachen k&#246;nnen bzw. notwendig zur LaTeX Klassen und Paket Programmierung sind. Im Folgenden versuche ich meine Erkenntnisse (vielleicht in einer Serie) hier darzustellen.<p>

<p>F&#252;r die TeX Kommandoes empfehle ich ebenfalls in diese Liste zu schauen: <a href="http://www.tug.org/utilities/plain/cseq.html" class="liexternal">TeX Primitive Control Sequences</a>.</p>

<span id="more-173"></span>

<h3 id="toc-variablen-von-tex-latex">Variablen von TeX / LaTeX</h3>
Es gibt Z&#228;hlervariablen (int), L&#228;ngenvariablen (float) und Wahrheitswerte (bool) sowie Makros die Strings und Befehle enthalten k&#246;nnen. Eine Klassische Einteilung in int, float, bool, string gibt es nicht. 

<h4 id="toc-zahlervariablen-counter">Z&#228;hlervariablen (counter)</h4>

Counter speichern Integer Werte. Die Deklaration erfolgt &#252;ber


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycounter</span><span style="color: #E02020; ">}</span></pre></div></div>




Der Wert wird dabei mit 0 initialisiert. Eine Ver&#228;nderung erfolgt &#252;ber


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\setcounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycounter</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">2</span><span style="color: #E02020; ">}</span></pre></div></div>




Den Wert erh&#228;lt man als Zahl &#252;ber


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\value</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycounter</span><span style="color: #E02020; ">}</span></pre></div></div>




diese Ausgabe ist allerdings nur innerhalb der Programmierung nutzbar.
Die Textausgabe hingegen erh&#228;lt man durch ein Voranstellen von <code>\the</code>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\themycounter</span></pre></div></div>



m&#246;chte man die Ausgabe in einer bestimmten Notation ist dies m&#246;glich durch


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\arabic</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycnt</span><span style="color: #E02020; ">}</span>  <span style="color: #2C922C; font-style: italic;">% Wert von mycounter als Textstring in arabischen Ziffern</span>
<span style="color: #800000; font-weight: normal;">\roman</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycnt</span><span style="color: #E02020; ">}</span>  <span style="color: #2C922C; font-style: italic;">% Wert von mycounter als Textstring in römischen Ziffern</span></pre></div></div>




von diesen Notationen gibt es weitere die hier nicht aufgef&#252;hrt sind.

Zur Rechnung stehen Counter nicht direkt zur Verf&#252;gung. Man kann sie jedoch einstellen und erh&#246;hen:


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\setcounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycounter</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">2</span><span style="color: #E02020; ">}</span>     <span style="color: #2C922C; font-style: italic;">% mycounter = 2</span>
<span style="color: #800000; font-weight: normal;">\addtocounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycounter</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">4</span><span style="color: #E02020; ">}</span>  <span style="color: #2C922C; font-style: italic;">% mycounter = 6</span>
<span style="color: #800000; font-weight: normal;">\addtocounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycounter</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\value</span><span style="color: #E02020; ">{</span>othercounter</span><span style="color: #E02020; ">}}</span></pre></div></div>




Eine Erh&#246;hung speziell um 1 erfolgt &#252;ber


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\stepcounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycounter</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">% Zähler um 1 inkrementieren</span></pre></div></div>




<h4 id="toc-langenvariablen-length">L&#228;ngenvariablen (length)</h4>
Die L&#228;ngenvariablen entsprechen Flieskommazahlen (float) in eine gew&#246;hnlichen Programmiersprache. Diese L&#228;ngen werden in Abh&#228;ngigkeit einer Ma&#223;einheit (mm, cm, pt. . . ) abgespeichert. Die Definition und Zuweisung erfolgt analog zu den countern


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newlength</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\mylen</span></span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">%Deklaration</span>
<span style="color: #800000; font-weight: normal;">\setlength</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\mylen</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">&lt;NeueLänge&gt;</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">%Zuweisung</span>
<span style="color: #800000; font-weight: normal;">\addtolength</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\mylen</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">&lt;ZusatzLänge&gt;</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">% Operator</span></pre></div></div>




L&#228;ngen k&#246;nnen auch variabel sein:


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\setlength</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\mylen</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">&lt;NeueLänge&gt;plus &lt;P&gt; minus &lt;M&gt;</span><span style="color: #E02020; ">}</span></pre></div></div>




Die Textausgabe  erh&#228;lt man durch ein Voranstellen von <code>\the</code>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\the</span><span style="color: #800000; font-weight: normal;">\mylen</span></pre></div></div>




Die Ausgabe zwischen Countern und L&#228;ngen ist somit unterschiedlich


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mycounter</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\themycounter</span>
<span style="color: #800000; font-weight: normal;">\newlength</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\mylength</span></span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\the</span><span style="color: #800000; font-weight: normal;">\mylength</span></pre></div></div>




Die jeweiligen TeX &#196;quivalente werden jedoch beide mit \the vorgestellt ausgegeben.


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcount</span><span style="color: #800000; font-weight: normal;">\mycounter</span>
<span style="color: #800000; font-weight: normal;">\the</span><span style="color: #800000; font-weight: normal;">\mycounter</span>
<span style="color: #800000; font-weight: normal;">\newskip</span><span style="color: #800000; font-weight: normal;">\mylength</span>
<span style="color: #800000; font-weight: normal;">\the</span><span style="color: #800000; font-weight: normal;">\mylength</span></pre></div></div>




Eine interessante Funktion in diesem Zusammenhang ist <code>\settowidth</code> welche die L&#228;nge eines Textes vermisst und in einem L&#228;ngenregister speichert.


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\settowidth</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\mylen</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">Text</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">% misst die Breite von &quot;Text&quot;</span></pre></div></div>




<h4 id="toc-wahrheitswerte-boolean">Wahrheitswerte (boolean)</h4>
Die Wahrheitswerte entsprechen boolschen Variablen in eine gew&#246;hnlichen Programmiersprache. Hierf&#252;r wird das Paket <em>ifthen</em> ben&#246;tigt. Die Definition und Zuweisung erfolgt analog zu den Countern und L&#228;ngen


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">boolvar</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">%Deklaration</span>
<span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">boolvar</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">false</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">%Zuweisung</span></pre></div></div>



Eine Abfrage des Werten erfolgt &#252;ber


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\boolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">boolvar</span><span style="color: #E02020; ">}</span></pre></div></div>




welcher z.B. bei if Abfragen genutzt wird


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\ifthenelse</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\boolean</span><span style="color: #E02020; ">{</span>boolvar</span><span style="color: #E02020; ">}}{</span><span style="color: #2020C0; font-weight: normal;">}{</span><span style="color: #E02020; ">}</span></pre></div></div>




<h3 id="toc-rechnen-innerhalb-von-tex">Rechnen innerhalb von TeX</h3>
<ul>
	<li><code>\advance</code><br />


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\advance</span>&lt;Numerische Variable&gt; by &lt;Zahl&gt;</pre></div></div>



</li>
	<li><code>\divide</code><br />


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\divide</span>&lt;Numerische Variable&gt; by &lt;Zahl&gt;</pre></div></div>



</li>
	<li><code>\multiply</code><br />


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\multiply</span>&lt;Numerische Variable&gt; by &lt;Zahl&gt;</pre></div></div>



</li>
</ul>

<h3 id="toc-if-abfrage">If Abfrage</h3>
TeX kennt die Struktur


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\if</span>
...
<span style="color: #800000; font-weight: normal;">\else</span>
...
<span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>




wobei es eine gr&#246;&#223;ere Anzahl von vordefinierten If-Abragen gibt


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\ifundefined</span>
<span style="color: #800000; font-weight: normal;">\ifnum</span>
<span style="color: #800000; font-weight: normal;">\ifodd</span>
<span style="color: #800000; font-weight: normal;">\ifdim</span>
<span style="color: #800000; font-weight: normal;">\iftrue</span>
<span style="color: #800000; font-weight: normal;">\iffalse</span>
<span style="color: #800000; font-weight: normal;">\ifx</span>
...</pre></div></div>




Hier einige Beispiel dazu 

<ul>
	<li>Test ob der Wert eines  Counter <code>\count0</code> kleiner ist als 100


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\ifnum</span><span style="color: #800000; font-weight: normal;">\count</span>0&lt;100
...
<span style="color: #800000; font-weight: normal;">\else</span> ... <span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>



</li>
	<li>Vergleich zweier Integerwerte


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% Alles TeX und kein LaTeX Code!</span>
<span style="color: #800000; font-weight: normal;">\newcount</span><span style="color: #800000; font-weight: normal;">\WertA</span>
<span style="color: #800000; font-weight: normal;">\newcount</span><span style="color: #800000; font-weight: normal;">\WertB</span>
<span style="color: #800000; font-weight: normal;">\WertA</span>=20
<span style="color: #800000; font-weight: normal;">\WertB</span>=<span style="color: #800000; font-weight: normal;">\WertA</span>
<span style="color: #800000; font-weight: normal;">\ifnum</span><span style="color: #800000; font-weight: normal;">\WertA</span>=<span style="color: #800000; font-weight: normal;">\WertB</span>
	Werte stimmen überein
<span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>



</li>
	<li>Vergleich von Dimensionswerten (L&#228;ngen): <code>\ifdim</code>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newlength</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\firstlen</span></span><span style="color: #E02020; ">}</span> 
<span style="color: #800000; font-weight: normal;">\newlength</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\secondlen</span></span><span style="color: #E02020; ">}</span> 
<span style="color: #800000; font-weight: normal;">\settowidth</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\firstlen</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">Text</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">% misst die Breite von &quot;Text&quot;</span>
<span style="color: #800000; font-weight: normal;">\settowidth</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\secondlen</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">anderer Text</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">% misst die Breite von &quot;anderer Text&quot;</span>
<span style="color: #800000; font-weight: normal;">\ifdim</span><span style="color: #800000; font-weight: normal;">\firstlen</span>=<span style="color: #800000; font-weight: normal;">\secondlen</span>
	Werte sind gleich und haben die Länge <span style="color: #800000; font-weight: normal;">\thefirstlen</span>
<span style="color: #800000; font-weight: normal;">\else</span>
	Werte sind ungleich
<span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>



Latex kennt das Kommando <code>\lengthtest{1pt < 2pt}</code> was dem <code>\ifdim</code> entspricht.
</li>
	<li>Testen ob eine Makro definiert ist (eine Definition als <code>\relax</code> reicht daf&#252;r aus)


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\ifundefined</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">TeX</span><span style="color: #E02020; ">}</span> 
	true text 
<span style="color: #800000; font-weight: normal;">\else</span> 
	false text 
<span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>



hierf&#252;r gibt es allerdings noch weitere M&#246;glichkeiten, siehe dazu auch <a href="/blog/2007/05/31/existenz-von-paketen-pruefen/" class="liinternal">Existenz von Paketen pr&#252;fen</a>
</li>
	<li>Testen von 'Gleichheit' zweier Makros ohne Sie zu expandieren: <code>\ifx</code>. Hier ein Beispiel aus dem TeXBook


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">def</span></span><span style="color: #800000; font-weight: normal;">\a</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\c</span></span><span style="color: #E02020; ">}</span> 
<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">def</span></span><span style="color: #800000; font-weight: normal;">\b</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\d</span></span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">def</span></span><span style="color: #800000; font-weight: normal;">\c</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\e</span></span><span style="color: #E02020; ">}</span> 
<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">def</span></span><span style="color: #800000; font-weight: normal;">\d</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\e</span></span><span style="color: #E02020; ">}</span> 
<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">def</span></span><span style="color: #800000; font-weight: normal;">\e</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">A</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\ifx</span><span style="color: #800000; font-weight: normal;">\c</span><span style="color: #800000; font-weight: normal;">\d</span>
	 wahr
<span style="color: #800000; font-weight: normal;">\fi</span>
<span style="color: #800000; font-weight: normal;">\ifx</span><span style="color: #800000; font-weight: normal;">\a</span><span style="color: #800000; font-weight: normal;">\b</span>
	 nicht wahr
<span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>



Die Frage wann das Ergebnis true zur&#252;ckgibt ist komplex und wird vom TeXBook wie folgt beschrieben
<blockquote>
The condition is true if (a) the two tokens are not macros, and they both represent the same (character code, category code) pair or the same TEX primitive or the same \font or \chardef or \countdef, etc.; or if (b) the two tokens are macros, and they both have the same status with respect to \long and \outer, and they both have the same parameters and &ldquo;top level&rdquo; expansion.
</blockquote>
</li>
</ul>
LaTeX bietet zum Testen von If Abfragen noch die Befehle <code>\equal {\Makro }{ ABC }</code>, <code>\and</code>, <code>\or</code>, <code>\not</code> sowie zum Schachteln von Bedingungen die Klammern , <code>\(</code> und , <code>\)</code>.


<h4 id="toc-ifcase-anweisung"><code>\ifcase</code> Anweisung</h4>
Diese Abfrage ist vergleichbar mit einer switch Anweisung. Sie hat die Syntax


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\ifcase</span><span style="color: #800000; font-weight: normal;">\number</span> 
         text for case 0 
<span style="color: #800000; font-weight: normal;">\or</span> 
         text for case 1 
<span style="color: #800000; font-weight: normal;">\or</span>
         ...
<span style="color: #800000; font-weight: normal;">\or</span>
          text for case n
 <span style="color: #800000; font-weight: normal;">\else</span> 
         text for all other cases 
<span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>



Hierbei wird &#252;ber die Zahlen von \number die Anweisung ausgew&#228;hlt.

<h3 id="toc-tex-funktionen">TeX Funktionen</h3>
Nur eine Auswahl...
<ul>
	<li><code>\string</code><br /> gibt ein folgendes Kommando inklusive dem Backspace aus</li>
	<li><code>\relax</code><br />Donald Knuth schreibt dazu das es TeX sagt:"do nothing." Dar&#252;ber hinaus f&#252;hrt es dazu dass Makros die auf darauffolgende Tokens agieren mit diesem Befehl keine weiteren Token aktzeptieren.</li>
</ul>

<h3 id="toc-latex-funktionen">LaTeX Funktionen</h3>
Nur eine Auswahl...
<ul>
	<li><code>\g@addto@macro</code><br /> 
H&#228;ngt weitere Befehle an ein bestehendes Makro an


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\g</span>@addto@macro<span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">\&lt;macroname&gt;</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">&lt;Zus. Befehle&gt;</span><span style="color: #E02020; ">}</span></pre></div></div>



</li>
</ul>

<h3 id="toc-schleifen">Schleifen</h3>
<h4 id="toc-whiledo-nur-latex">\whiledo (nur LaTex)</h4>
Ben&#246;tigt das Paket <em>ifthen</em>. Im Beispiel wird zus&#228;tzlich das Paket <em>pifont</em> ben&#246;tigt.


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">ctra</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\setcounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">ctra</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">1</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\whiledo</span> <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\value</span><span style="color: #E02020; ">{</span>ctra</span><span style="color: #E02020; ">}</span> &lt; 7<span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">{</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #800000; font-weight: normal;">\thectra</span> <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\large</span> <span style="color: #800000; font-weight: normal;">\ding</span><span style="color: #E02020; ">{</span>111</span><span style="color: #E02020; ">}}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #800000; font-weight: normal;">\stepcounter</span> <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">ctra</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}</span></pre></div></div>



Ausgabe:<br/>
<img src='/latexrender/pictures/96a775588b27c131ca26ee379f8fdee8.png' title='\newcounter{ctra}\setcounter{ctra}{1}\whiledo {\value{ctra} &lt; 7}{\thectra {\large \ding{111}}\stepcounter {ctra}}' alt='\newcounter{ctra}\setcounter{ctra}{1}\whiledo {\value{ctra} &lt; 7}{\thectra {\large \ding{111}}\stepcounter {ctra}}' align=absmiddle>

<h4 id="toc-loop-tex">\loop (TeX)</h4>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\loop</span>
	<span style="color: #800000; font-weight: normal;">\ifnum</span><span style="color: #800000; font-weight: normal;">\n</span>&gt;0 <span style="color: #2C922C; font-style: italic;">% Abbruchbedingung (\if ohne \fi)</span>
...
<span style="color: #800000; font-weight: normal;">\repeat</span></pre></div></div>




<h4 id="toc-for-schleife-latex">For Schleife (LaTeX)</h4>
Das <em>forloop</em> Paket stellt eine for Schleife zur Verf&#252;gung.


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newcounter</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">ct</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\forloop</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">ct</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">1</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\value</span><span style="color: #E02020; ">{</span>ct</span><span style="color: #E02020; ">}</span> &lt; 5<span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">{</span><span style="color: #2C922C; font-style: italic;">%</span>
	<span style="color: #800000; font-weight: normal;">\arabic</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">ct</span><span style="color: #E02020; ">}</span>
<span style="color: #E02020; ">}</span></pre></div></div>



Ausgabe:<br/>
<img src='/latexrender/pictures/040bfdd7faff0ef7a15fd9ed06d00cda.png' title='\newcommand{\forloop}[5][1]{\setcounter{#2}{#3}\ifthenelse{#4}{#5\addtocounter{#2}{#1}    \forloop[#1]{#2}{\value{#2}}{#4}{#5}}{}}\newcounter{ct}\forloop{ct}{1}{\value{ct} &lt; 5}{\arabic{ct}}' alt='\newcommand{\forloop}[5][1]{\setcounter{#2}{#3}\ifthenelse{#4}{#5\addtocounter{#2}{#1}    \forloop[#1]{#2}{\value{#2}}{#4}{#5}}{}}\newcounter{ct}\forloop{ct}{1}{\value{ct} &lt; 5}{\arabic{ct}}' align=absmiddle>


<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2008/07/20/bbclone-in-mediawiki/' rel='bookmark' title='Permanent Link: bbclone in mediawiki'>bbclone in mediawiki</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/' rel='bookmark' title='Permanent Link: LaTeX Wiki'>LaTeX Wiki</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/05/31/existenz-von-paketen-pruefen/' rel='bookmark' title='Permanent Link: Existenz von Paketen pr&#252;fen'>Existenz von Paketen pr&#252;fen</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>LaTeX Wiki</title>
		<link>http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/</link>
		<comments>http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 08:52:49 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[wikis]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/</guid>
		<description><![CDATA[HintergrundInhalteExistierende LaTeX Wikiswww.latexwiki.org

Hintergrund
Die LaTeX Community verf&#252;gt &#252;ber eine Vielzahl an Webseiten, darunter jedoch nur sehr wenige die als zentrale Anlaufstellen gelten k&#246;nnen. Dass der Bedarf an Webseiten zum Thema LaTeX gro&#223; ist kann ich an den Besucherzahlen meiner Seiten einsehen, da diese pro Monat in der Gr&#246;&#223;enordnung von 20.000 Hits liege. Meine eigene Seite ist [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/08/08/converting-latex-output-into-images-on-a-webserver/' rel='bookmark' title='Permanent Link: Converting LaTeX output into images on a webserver'>Converting LaTeX output into images on a webserver</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/07/22/mediawiki-and-latex/' rel='bookmark' title='Permanent Link: mediawiki and LaTeX'>mediawiki and LaTeX</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/07/21/mediawiki-plugins/' rel='bookmark' title='Permanent Link: Mediawiki Plugins'>Mediawiki Plugins</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<a id="toc"></a><ol class="toc"><li><a href="http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/#toc-hintergrund" class="liinternal">Hintergrund</a></li><li><a href="http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/#toc-inhalte" class="liinternal">Inhalte</a></li><li><a href="http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/#toc-existierende-latex-wikis" class="liinternal">Existierende LaTeX Wikis</a></li><li><a href="http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/#toc-www-latexwiki-org" class="liinternal">www.latexwiki.org</a></li></ol>

<h3 id="toc-hintergrund">Hintergrund</h3>
Die LaTeX Community verf&#252;gt &#252;ber eine Vielzahl an Webseiten, darunter jedoch nur sehr wenige die als zentrale Anlaufstellen gelten k&#246;nnen. Dass der Bedarf an Webseiten zum Thema LaTeX gro&#223; ist kann ich an den Besucherzahlen meiner Seiten einsehen, da diese pro Monat in der Gr&#246;&#223;enordnung von 20.000 Hits liege. Meine eigene Seite ist jedoch von mir nicht daf&#252;r ausgelegt von verschiedenen Autoren bearbeitet zu werden (auch wenn das durchaus m&#246;glich w&#228;re). Dies w&#252;rde jedoch ein Wiki erm&#246;glichen. Dabei stellt sich ganz grunds&#228;tzlich die Frage welche Inhalte in einem solchen Wiki enthalten sein k&#246;nnten.

<span id="more-147"></span>

<h3 id="toc-inhalte">Inhalte</h3>
M&#246;gliche Inhalte eines LaTeX Wikis
<ul>
	<li>Verlinkung und Beschreibung der wesentlichen Dokumentation und Webseiten sortiert nach Themen. Das ist der Ausgangspunkt dieser Seite und sehr erfolgreich.</li>
	<li>Erstellung von kleinen Tutorials (Howtos). Diese gibt es nat&#252;rlich auch als Dokumente (pdf) und FAQs. Hier steht jedoch die M&#246;glichkeit der schnellen Verf&#252;gbarkeit im Vordergrund. Sollte ein Artikel im Wiki ausgereift sein kann man noch immer ein Dokument daraus machen.</li>
	<li>Ein &#196;quivalent zu selfhtml. Mit der M&#246;glichkeit den Quellcode und das LaTeX Ergebnis darzustellen ergeben sich M&#246;glichkeiten die in der Form bislang nicht online verf&#252;gbar sind.</li>
	<li>Jedoch keine Erstellung oder Duplikation von Dokumentationen, da diese besser in Dokumenten aufgehoben sind</li>
</ul>

<h3 id="toc-existierende-latex-wikis">Existierende LaTeX Wikis</h3>
Betrachten wir zuerst die existierenden LaTeX Wiki Webseiten:
<ul>
	<li><a href="http://latex.wissens-quelle.de/" class="liexternal">http://latex.wissens-quelle.de/</a></li>
	<li><a href="http://www.wurmloch.ch/latexwiki/" class="liexternal">http://www.wurmloch.ch/latexwiki/</a></li>
	<li><a href="http://www.kkittel.de/wiki/index.php?title=Hauptseite" class="liexternal">http://www.kkittel.de/wiki/</a></li>
</ul>

Die beiden ersten Webseiten erscheinen mir keine optimale L&#246;sung f&#252;r eine LaTeX Wiki zu sein. Die erste hat eine mir vollkommen unbekannte Wikisoftware, so dass ich vermute dass diese vom Autor selbst programmiert wurde. Dies erscheint mir kein guter Ausgangspunkt f&#252;r sp&#228;tere &#196;nderungen an den M&#246;glichkeiten der Wikisoftware zu sein, vergleicht man diese mit den Extensions die mediawiki bietet (z.B. Export nach latex, xml oder pdf). Zudem enth&#228;lt die Seite fast keinen Inhalt. Die zweite Seite hat ebenso wie die erste einen merkw&#252;rdigen Dom&#228;nennamen. Sie basiert auf mediawiki, enth&#228;lt jedoch anscheint keine wikitex Extension. Leider ist die Seite ohne Stuktur auf der Startseite und enth&#228;lt relativ wenig Inhalt (siehe <a href="http://www.wurmloch.ch/latexwiki/index.php?title=Spezial:Alle_Seiten" class="liexternal">Spezial:Alle Seiten</a>), der zudem h&#228;ufig Fehler enth&#228;lt die in <a href="ftp://ftp.dante.de/pub/tex/info/german/l2tabu/l2tabu.pdf" class="lipdf">l2tabu.pdf</a> dokumentiert sind.
Die dritte Webseite besticht durch eine sehr &#252;bersichtliche Startseite. Leider ist auch diese Seite an die Dom&#228;ne des Administrators gebunden und hat leider als Editor nur den Administrator. Von den Inhalten her ist diese Seite wie die anderen auch relativ leer, dennoch besticht die Gegen&#252;berstellung von Quellcode und Ergebnissen, wie z.B. bei <a href="http://www.kkittel.de/wiki/index.php?title=Einfache_Listen" class="liexternal">Einfache Listen</a>. Leider beruht dies ebenfalls nicht auf wikitex, sondern nutzt hochgeladene Bilder.

Nicht unerw&#228;hnt bleiben sollten die wikibooks (<a href="http://en.wikibooks.org/wiki/LaTeX" class="liexternal">http://en.wikibooks.org/wiki/LaTeX</a>) zu LaTeX. Diese beruhen selbstverst&#228;ndlich auf einem Wiki haben jedoch ein sehr klaren und eingegrenzten Aufgabenbereich und sind daher kein LaTeX Wiki in dem hier beschriebenen Sinne.

<h3 id="toc-www-latexwiki-org">www.latexwiki.org</h3>
Aufgrund der Diskussion im <a href="http://www.mrunix.de/forums/forumdisplay.php?f=38" class="liexternal">LaTeX Forum</a> zur <a href="http://www.mrunix.de/forums/showthread.php?t=52196" class="liexternal">Erstellung eines LaTeX Wikis</a> habe ich ein Wiki mit mediawiki aufgesetzt, dass &#252;ber ausreichend Erweiterungen verf&#252;gt die mir notwendig und sinnvoll erscheinen, sowie die M&#246;glichkeit bietet LaTeX auf der Webseite mittels wikitex &#252;bersetzen zu lassen. Daf&#252;r musste ich allerdings wikitex ein wenig umschreiben.

Diese Wiki ist inzwischen online unter: <a href="http://www.latexwiki.org/" class="liexternal">http://www.latexwiki.org/</a>. 

Auf folgende Unterseiten m&#246;chte ich dabei hinweisen:
<ul>
	<li><a href="http://www.latexwiki.org/Erweiterungen" class="liexternal">Erweiterungen</a> Syntaxhighlighting und LaTeX Ausgabe</li>
	<li><a href="http://www.latexwiki.org/LaTeX_Community" class="liexternal">LaTeX Community</a></li>
</ul>

Die Struktur der Webseite ist bislang nur eine Vorstellung dessen was m&#246;glich ist und was mir sinnvoll erschien. Da ich die Webseite nicht als mein Projekt ansehe ist es jedem registrierten Benutzer freigestellt dies umzustellen.
Die Startseite bedarf jedoch in jeder Weise noch einer &#220;berarbeitung.

Ich hoffe das diese Webseite in Zukunft auch genutzt und vor allem mit Inhalten gef&#252;llt wird.






<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/08/08/converting-latex-output-into-images-on-a-webserver/' rel='bookmark' title='Permanent Link: Converting LaTeX output into images on a webserver'>Converting LaTeX output into images on a webserver</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/07/22/mediawiki-and-latex/' rel='bookmark' title='Permanent Link: mediawiki and LaTeX'>mediawiki and LaTeX</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/07/21/mediawiki-plugins/' rel='bookmark' title='Permanent Link: Mediawiki Plugins'>Mediawiki Plugins</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting LaTeX output into images on a webserver</title>
		<link>http://www.matthiaspospiech.de/blog/2007/08/08/converting-latex-output-into-images-on-a-webserver/</link>
		<comments>http://www.matthiaspospiech.de/blog/2007/08/08/converting-latex-output-into-images-on-a-webserver/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 07:30:06 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[wikis]]></category>

		<guid isPermaLink="false">http://www.matthiaspospiech.de/blog/2007/08/08/converting-latex-output-into-images-on-a-webserver/</guid>
		<description><![CDATA[With my new website http://www.latexwiki.org I needed a way to convert the output of latex to an image in png format. Standard solutions for doing this on a webserver are the php class latexrender or the mediawiki extension wikitex. Since the wiki uses mediawiki I customised wikitex to my needs.

The solutions to convert the latex [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/07/22/mediawiki-and-latex/' rel='bookmark' title='Permanent Link: mediawiki and LaTeX'>mediawiki and LaTeX</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/' rel='bookmark' title='Permanent Link: LaTeX Wiki'>LaTeX Wiki</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/08/23/convert-images-in-batch-process/' rel='bookmark' title='Permanent Link: convert Images in batch process'>convert Images in batch process</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[With my new website <a href="http://www.latexwiki.org" class="liexternal">http://www.latexwiki.org</a> I needed a way to convert the output of latex to an image in png format. Standard solutions for doing this on a webserver are the php class <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/latexrender.html" class="liexternal">latexrender</a> or the mediawiki extension <a href="http://wikitex.org/" class="liexternal">wikitex</a>. Since the wiki uses mediawiki I customised wikitex to my needs.

The solutions to convert the latex output are the following

<ul>
	<li><strong>latex + dvipng</strong><br />
		<a href="http://savannah.nongnu.org/projects/dvipng/" class="liexternal">dvipng</a> creates for each page in the dvi file a new png image. This tool is used by wikitex and has the advantage of being very fast. However, it is not possible to include postscript code into the images with dvipng and thus eps images in the tex file are not converted into the png file.


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dvipng <span style="color: #660033;">-gamma</span> <span style="color: #000000;">1.5</span> <span style="color: #660033;">-T</span> tight <span style="color: #800000;">${HASH}</span></pre></div></div>



</li>
	<li><strong>latex + dvips + convert</strong><br />
		dvips converts the dvi files to postscript files with the option <em>E</em> so that every page is put into a different file. This approach is used by class.latexrender.php. Afterwards the ps files can be converted with ghosscript via convert to pngs.


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PS</span>=<span style="color: #ff0000;">'.ps'</span>
dvips <span style="color: #660033;">-E</span> <span style="color: #800000;">${HASH}</span>.dvi <span style="color: #660033;">-o</span> <span style="color: #800000;">${HASH}</span>.ps
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${HASH}</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #800000;">${PS}</span>; <span style="color: #000000; font-weight: bold;">do</span> 
    convert <span style="color: #660033;">-density</span> <span style="color: #000000;">120</span> <span style="color: #660033;">-trim</span> <span style="color: #800000;">${i}</span> <span style="color: #800000;">${i}</span>.png
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>



</li>
	<li><strong>pdflatex + pdftoppm + convert</strong><br />
		This approach works with pdflatex and should be much faster than using ghostscript.


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PPM</span>=<span style="color: #ff0000;">'.ppm'</span>
pdftoppm <span style="color: #800000;">${HASH}</span>.pdf <span style="color: #800000;">${HASH}</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${HASH}</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #800000;">${PPM}</span>; <span style="color: #000000; font-weight: bold;">do</span> 
   convert <span style="color: #800000;">${i}</span> <span style="color: #800000;">${i}</span>.png
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>



</li>
</ul>



<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/07/22/mediawiki-and-latex/' rel='bookmark' title='Permanent Link: mediawiki and LaTeX'>mediawiki and LaTeX</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/' rel='bookmark' title='Permanent Link: LaTeX Wiki'>LaTeX Wiki</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/08/23/convert-images-in-batch-process/' rel='bookmark' title='Permanent Link: convert Images in batch process'>convert Images in batch process</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2007/08/08/converting-latex-output-into-images-on-a-webserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX In Word and Powerpoint</title>
		<link>http://www.matthiaspospiech.de/blog/2007/07/10/latex-in-word-and-powerpoint/</link>
		<comments>http://www.matthiaspospiech.de/blog/2007/07/10/latex-in-word-and-powerpoint/#comments</comments>
		<pubDate>Tue, 10 Jul 2007 06:59:17 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://www.pospiech.eu/blog/2007/07/10/latex-in-word-and-powerpoint/</guid>
		<description><![CDATA[List of Software that can be used in Word or Powerpoint:

	Aurora (former Ribbit)
	TeXPoint





Related posts:LaTeX Wiki



Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/' rel='bookmark' title='Permanent Link: LaTeX Wiki'>LaTeX Wiki</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[List of Software that can be used in Word or Powerpoint:
<ul>
	<li><a href="http://elevatorlady.ca/" class="liexternal">Aurora (former Ribbit)</a></li>
	<li><a href="http://texpoint.necula.org/" class="liexternal">TeXPoint</a></li>
</ul>




<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2007/08/08/latex-wiki/' rel='bookmark' title='Permanent Link: LaTeX Wiki'>LaTeX Wiki</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2007/07/10/latex-in-word-and-powerpoint/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Syntaxhighlighting von LaTeX in Webseiten</title>
		<link>http://www.matthiaspospiech.de/blog/2007/06/25/syntaxhighlighting-von-latex-in-webseiten/</link>
		<comments>http://www.matthiaspospiech.de/blog/2007/06/25/syntaxhighlighting-von-latex-in-webseiten/#comments</comments>
		<pubDate>Mon, 25 Jun 2007 20:46:18 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.pospiech.eu/blog/2007/06/25/syntaxhighlighting-von-latex-in-webseiten/</guid>
		<description><![CDATA[F&#252;r Wordpress existieren mehrere Pugins f&#252;r den GeSHi &#8211; Generic Syntax Highlighter for php. Mit diesem l&#228;sst sich sehr einfach Quellcode in &#252;ber 50 verschiedenen Sprachen farbig hervorgehoben auf Webseiten darstellen. Letztes Jahr habe ich aufbauend auf einer Vorlage von Thomas Efer eine Sprachvorgabedatei f&#252;r LaTeX erstellt. 
In Zusammenarbeit mit dem Programmierer von GeSHi (Nigel [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2008/08/04/alternatives-syntaxhighlighting/' rel='bookmark' title='Permanent Link: Alternatives Syntaxhighlighting'>Alternatives Syntaxhighlighting</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/' rel='bookmark' title='Permanent Link: LaTeX Variablen, If Abfragen und Schleifen'>LaTeX Variablen, If Abfragen und Schleifen</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>F&#252;r Wordpress existieren mehrere Pugins f&#252;r den <a href="http://qbnz.com/highlighter/" class="liexternal">GeSHi &#8211; Generic Syntax Highlighter for php</a>. Mit diesem l&#228;sst sich sehr einfach Quellcode in &#252;ber 50 verschiedenen Sprachen farbig hervorgehoben auf Webseiten darstellen. Letztes Jahr habe ich aufbauend auf einer Vorlage von Thomas Efer eine Sprachvorgabedatei f&#252;r LaTeX erstellt. 
In Zusammenarbeit mit dem Programmierer von GeSHi (Nigel McNie) sind weitere Verbesserungen hinzugekommen. </p>

<span id="more-128"></span>
<p>Wie ich beim letzen Update von Wordpress und den Plugins feststellen konnte wird diese Datei inzwischen bei GeSHi mitgeliefert.
Ein Beispiel der Syntax Hervorhebungen ist im folgenden Beispiel zu sehen:</p>


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% Beispieldokument</span>
<span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">documentclass</span></span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">a4paper, 11pt,german</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">scrartcl</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">lmodern</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">textcomp</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">german</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">babel</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">T1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">fontenc</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">latin1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">inputenc</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">graphicx</span><span style="color: #E02020; ">}</span>
<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span>
	<span style="color: #8020E0; font-weight: normal;">$ a = b + c $</span>
	<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">equation</span></span><span style="color: #E02020; ">}</span><span style="color: #8020E0; font-weight: normal;">
		a = b + c
	</span><span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">equation</span></span><span style="color: #E02020; ">}</span>
	<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">figure</span></span><span style="color: #E02020; ">}</span>
		<span style="color: #800000; font-weight: normal;">\includegraphics</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">Bild.png</span><span style="color: #E02020; ">}</span>
	<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">figure</span></span><span style="color: #E02020; ">}</span>
	<span style="color: #800000; font-weight: normal;">\section</span><span style="color: #E02020; ">{</span><span style="color: #00008B; font-weight: bold;">Einleitung</span><span style="color: #E02020; ">}</span>
	Dies ist ein beliebig langer Satz ohne konkreten Hintergrund.
	<span style="color: #800000; font-weight: normal;">\cite</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">S. 22</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">Mustermann</span><span style="color: #E02020; ">}</span>
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span></pre></div></div>




Nat&#252;rlich ist das Syntaxhighlighting noch nicht perfekt. Einige Dinge lie&#223;en sich in der jetzigen Version von Geshi noch nicht umsetzen f&#252;r andere fehlte mir die notwendige Kenntnis von Regul&#228;ren Ausdr&#252;cken und die Zeit. 

<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2008/08/04/alternatives-syntaxhighlighting/' rel='bookmark' title='Permanent Link: Alternatives Syntaxhighlighting'>Alternatives Syntaxhighlighting</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/' rel='bookmark' title='Permanent Link: LaTeX Variablen, If Abfragen und Schleifen'>LaTeX Variablen, If Abfragen und Schleifen</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2007/06/25/syntaxhighlighting-von-latex-in-webseiten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Existenz von Paketen pr&#252;fen</title>
		<link>http://www.matthiaspospiech.de/blog/2007/05/31/existenz-von-paketen-pruefen/</link>
		<comments>http://www.matthiaspospiech.de/blog/2007/05/31/existenz-von-paketen-pruefen/#comments</comments>
		<pubDate>Thu, 31 May 2007 21:21:57 +0000</pubDate>
		<dc:creator>pospiech</dc:creator>
				<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://www.pospiech.eu/blog/2007/05/31/existenz-von-paketen-pruefen/</guid>
		<description><![CDATA[In meiner LaTeX Vorlage hatte ich Abfragen eingebaut die auf die Existenz von Befehlen als auch der geladenen Klassen pr&#252;fen. Davon ausgehend hat mich Markus Kohm darauf hingewiesen dass es grunds&#228;tzlich keine gute Idee ist auf die geladene Klasse zu pr&#252;fen wenn man nur daran interessiert ist ob eine Anweisung vorhanden ist (in meinem Fall [...]


Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/' rel='bookmark' title='Permanent Link: LaTeX Variablen, If Abfragen und Schleifen'>LaTeX Variablen, If Abfragen und Schleifen</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/18/tutorial-zu-expandafter/' rel='bookmark' title='Permanent Link: Tutorial zu \expandafter'>Tutorial zu \expandafter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[In meiner LaTeX Vorlage hatte ich Abfragen eingebaut die auf die Existenz von Befehlen als auch der geladenen Klassen pr&#252;fen. Davon ausgehend hat mich Markus Kohm darauf hingewiesen dass es grunds&#228;tzlich keine gute Idee ist auf die geladene Klasse zu pr&#252;fen wenn man nur daran interessiert ist ob eine Anweisung vorhanden ist (in meinem Fall z.B. der  Befehl \chapter) oder nicht.

Hier ein Beispiel zur Umsetzung der Pr&#252;fung auf Existenz der Anweisung \chapter

bool Variable definieren


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\newboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapteravailable</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">false</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span></pre></div></div>




M&#246;glichkeiten zum Testen der Existenz einer Anweisung
<ul>
	<li>TeX


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\begingroup</span><span style="color: #800000; font-weight: normal;">\expandafter</span><span style="color: #800000; font-weight: normal;">\expandafter</span><span style="color: #800000; font-weight: normal;">\expandafter</span><span style="color: #800000; font-weight: normal;">\endgroup</span>
<span style="color: #800000; font-weight: normal;">\expandafter</span><span style="color: #800000; font-weight: normal;">\ifx</span><span style="color: #800000; font-weight: normal;">\csname</span> chapter<span style="color: #800000; font-weight: normal;">\endcsname</span><span style="color: #800000; font-weight: normal;">\relax</span>
  <span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">false</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #800000; font-weight: normal;">\else</span>
  <span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">true</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>



	</li>
	<li>e-TeX


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% Is \chapter undefined? (needs e-TeX)</span>
<span style="color: #800000; font-weight: normal;">\ifcsname</span> chapter<span style="color: #800000; font-weight: normal;">\endcsname</span>
  <span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">true</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #800000; font-weight: normal;">\else</span>
  <span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">false</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #800000; font-weight: normal;">\fi</span></pre></div></div>



	</li>
	<li>feature of package scrkbase


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% Is \chapter undefined or relax?</span>
<span style="color: #800000; font-weight: normal;">\RequiresPackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">scrkbase</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\ifundefined</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapter</span><span style="color: #E02020; ">}{</span><span style="color: #2C922C; font-style: italic;">% using a beta feature of KOMA-Script</span>
  <span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">false</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">
  <span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span>chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">true</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}</span></pre></div></div>



	</li>
	<li>feature of KOMA-Script


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% Is \chapter undefined or relax and define it \relax,</span>
<span style="color: #2C922C; font-style: italic;">% if it was undefined</span>
<span style="color: #E00000; font-weight: normal;">\@ifundefined</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapter</span><span style="color: #E02020; ">}{</span><span style="color: #2C922C; font-style: italic;">% using a beta feature of KOMA-Script</span>
  <span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">false</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">
  <span style="color: #800000; font-weight: normal;">\setboolean</span><span style="color: #E02020; ">{</span>chapteravailable</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">true</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}</span></pre></div></div>



	</li>
</ul>


Die entg&#252;ltige Anweisung zum Test auf \chapter


<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\providecommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\IfChapterDefined</span></span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">1</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\ifthenelse</span><span style="color: #E02020; ">{</span><span style="color: #800000; font-weight: normal;">\boolean</span><span style="color: #E02020; ">{</span>chapteravailable</span><span style="color: #E02020; ">}}{</span><span style="color: #2020C0; font-weight: normal;">#1</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">}</span><span style="color: #E02020; ">}</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #800000; font-weight: normal;">\providecommand</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\IfElseChapterDefined</span></span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">2</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\ifthenelse</span><span style="color: #E02020; ">{</span><span style="color: #800000; font-weight: normal;">\boolean</span><span style="color: #E02020; ">{</span>chapteravailable</span><span style="color: #E02020; ">}}{</span><span style="color: #2020C0; font-weight: normal;">#1</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;">#2</span><span style="color: #E02020; ">}}</span><span style="color: #2C922C; font-style: italic;">%</span></pre></div></div>





<p>Related posts:<ol><li><a href='http://www.matthiaspospiech.de/blog/2008/04/13/latex-variablen-if-abfragen-und-schleifen/' rel='bookmark' title='Permanent Link: LaTeX Variablen, If Abfragen und Schleifen'>LaTeX Variablen, If Abfragen und Schleifen</a></li>
<li><a href='http://www.matthiaspospiech.de/blog/2008/04/18/tutorial-zu-expandafter/' rel='bookmark' title='Permanent Link: Tutorial zu \expandafter'>Tutorial zu \expandafter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.matthiaspospiech.de/blog/2007/05/31/existenz-von-paketen-pruefen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
