<?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>Some TeX Developments &#187; LaTeX3</title>
	<atom:link href="http://www.texdev.net/category/latex/latex3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.texdev.net</link>
	<description>Coding in the TeX world</description>
	<lastBuildDate>Sun, 22 Jan 2012 10:34:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Programming LaTeX3: More on token list variables</title>
		<link>http://www.texdev.net/2012/01/22/programming-latex3-more-on-token-list-variables/</link>
		<comments>http://www.texdev.net/2012/01/22/programming-latex3-more-on-token-list-variables/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 10:34:39 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>
		<category><![CDATA[Programming LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1265</guid>
		<description><![CDATA[In my previous post, I introduced the idea of a token list variable, the LaTeX3 term for a macro used to store ‘stuff’. Token list variables (tl vars) are the basis of many of the higher level data types in LaTeX3, and they also have arbitrary contents. As a result, there are a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a title="Programming LaTeX3: Token list variables" href="http://www.texdev.net/2011/12/26/programming-latex3-token-list-variables/">previous post</a>, I introduced the idea of a <em>token list variable</em>, the LaTeX3 term for a macro used to store ‘stuff’. Token list variables (tl vars) are the basis of many of the higher level data types in LaTeX3, and they also have arbitrary contents. As a result, there are a lot of generic functions to do things with tl vars.</p>
<h2>Adding content, changing content</h2>
<p>A very common thing to do with stored material is either to add to it, which we can do either on the left or the right. The LaTeX3 functions to do this are called <code>\tl_put_left:Nn</code> and <code>\tl_put_right:Nn</code> (and so on), which makes it easy to build up complicated material quite quickly. So</p>
<pre>\tl_new:N \l_my_a_tl
\tl_set:Nn \l_my_a_tl { stuff }
\tl_put_right:Nn \l_my_a_tl { ~here }
\tl_put_left:Nn \l_my_a_tl { My~ }
\tl_use:N \l_my_a_tl</pre>
<p>will print ‘My stuff here’.</p>
<p>That&#8217;s easy enough to do without LaTeX3 coding, but find-and-replace is a bit more involved. So the functions <code>\tl_replace_once:Nnn</code> and <code>\tl_replace_all:Nnn</code> are working a little harder:</p>
<pre>\tl_set:Nn \l_my_a_tl { stuff~to~change }
\tl_replace_once:Nnn \l_my_a_tl { change } { alter }
\tl_use:N \l_my_a_tl % 'stuff to alter'
\tl_replace_all:Nnn \l_my_a_tl { t } { q }
\tl_use:N \l_my_a_tl % 'squff to alqer'</pre>
<h2>Adding one tl var to another</h2>
<p>So far, I&#8217;ve added literal input to tl vars. That&#8217;s useful, but a very common task to to combine two or more variables together. To do that, we need a way to access the <em>content</em> of a variable. First, what doesn&#8217;t work is doing</p>
<pre>\tl_new:N \l_my_b_tl
\tl_set:Nn \l_my_a_tl { stuff }
\tl_set:Nn \l_my_b_tl { ~more~stuff }
\tl_put_right:Nn \l_my_a_tl { \l_my_b_tl }</pre>
<p>as what ends up inside <code>\l_my_a_tl</code> is <code>stuff\l_my_b_tl</code>.</p>
<p>This is where LaTeX3&#8242;s expansion control comes into play. So far, we&#8217;ve seen arguments of type <code>N</code> and <code>n</code>, but there are others. There are a number of other types, but I want here to introduce just one one: <code>V</code>. A <code>V</code>-type argument will pass the <em>value</em> of a variable, rather than its name. So the correct way to add the content of one token list variable to another is</p>
<pre>\tl_set:Nn \l_my_a_tl { stuff }
\tl_set:Nn \l_my_b_tl { ~more~stuff }
\tl_put_right:NV \l_my_a_tl \l_my_b_tl</pre>
<p>which results in <code>\l_my_a_tl</code> containing <code>stuff more stuff</code>.</p>
<p>Now, the LaTeX3 kernel does not provide every possible combination of argument types (although it does provide <code>\tl_put_right:NV</code>). That&#8217;s not a problem, as they can easily be created:</p>
<pre>\cs_generate_variant:Nn \tl_put_right:Nn { NV }</pre>
<p>This is a ‘soft’ process: if the variant requested already exists, nothing happens, but otherwise the variant is created. So provided the base function exists, you can always create any variants you need.</p>
<h2>Mappings</h2>
<p>Another key idea when working with tl vars is the ability to map to each token they contain. For that, there are again a couple of useful functions, <code>\tl_map_function:NN</code> and <code>\tl_map_inline:Nn</code>. The two differ mainly in <em>expandability</em>, a concept we&#8217;ve not covered just yet! I&#8217;ll be coming back to that in a later post, so for the moment I&#8217;ll just use <code>\tl_map_inline:Nn</code>.</p>
<p>What does a mapping do? Try</p>
<pre>\tl_set:Nn \l_my_a_tl { stuff }
\tl_map_inline:Nn \l_my_a_tl { I~saw~'#1'. \\ }</pre>
<p>and you should get a listing of each separate token in the tl var:</p>
<blockquote><p>I saw &#8216;s&#8217;.<br />
I saw &#8216;t&#8217;.<br />
I saw &#8216;u&#8217;.<br />
I saw &#8216;f&#8217;.<br />
I saw &#8216;f&#8217;.</p></blockquote>
<p>As you can hopefully see, within the second argument of <code>\tl_map_inline:Nn</code> the place holder <code>#1</code> is used to insert a single token from the tl var. For a more complicated tl var</p>
<pre>\tl_set:Nn \l_my_a_tl { { stuff } ~ { which } ~ is ~ { complicated } }
\tl_map_inline:Nn \l_my_a_tl { I~saw~'#1'. \\ }</pre>
<p>we get</p>
<blockquote><p>I saw &#8216;stuff&#8217;.<br />
I saw &#8216;which&#8217;.<br />
I saw &#8216;i&#8217;.<br />
I saw &#8216;s&#8217;.<br />
I saw &#8216;complicated&#8217;.</p></blockquote>
<p>So you&#8217;ll see that spaces are ignored by the mapping, and that a brace group counts as a single item.</p>
<p>I&#8217;ve not covered every token list and token list variable function, but hopefully the basic concepts are now laid out. In the next post, I&#8217;ll move on to some other concepts, so that we can being to put more structures together.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2012/01/22/programming-latex3-more-on-token-list-variables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Programming LaTeX3: Token list variables</title>
		<link>http://www.texdev.net/2011/12/26/programming-latex3-token-list-variables/</link>
		<comments>http://www.texdev.net/2011/12/26/programming-latex3-token-list-variables/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 12:19:31 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>
		<category><![CDATA[Programming LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1256</guid>
		<description><![CDATA[In the last post, I talked about the concept of a token list and some general functions which act on token lists. That&#8217;s fine if you just want to take some input and ‘do stuff’, but a very common requirement when programming is storing input, and for that we need variables. LaTeX3 provides a number [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a title="Programming LaTeX3: Category codes, tokens and token lists" href="http://www.texdev.net/2011/12/21/programming-latex3-category-codes-tokens-and-token-lists/">last post</a>, I talked about the concept of a token list and some general functions which act on token lists. That&#8217;s fine if you just want to take some input and ‘do stuff’, but a very common requirement when programming is storing input, and for that we need variables. LaTeX3 provides a number of different types of variable: we&#8217;ll start with perhaps the most general of all, the <em>token list variable</em>.</p>
<h2>Token list variables</h2>
<p>So what is a token list variable (‘<code>tl</code>’)? You might well guess from the name that its a way of storing a token list! As such, a <code>tl</code> can be used to hold just about anything, and indeed this means that several of the other variable types we&#8217;ll meet later are <code>tl</code>s with a special internal structure.</p>
<p>Before we can save anything in a <code>tl</code>, we need to create the variable: this is a general principle of programming LaTeX3. We can then store something inside the variable by setting it:</p>
<pre>\tl_new:N \l_mypkg_name_tl
\tl_set:Nn \l_mypkg_name_tl { Fred }</pre>
<p>Hopefully, the analysis of this code is not too hard. First, <code>\tl_new:N</code> creates a new token list variable which I&#8217;ve called <code>\l_mypkg_name_tl</code>. (I&#8217;ll explain how the naming works in a little while.) The second line will set the new <code>tl</code> to contain the text <code>Fred</code>. Assuming that the surrounding code has done nothing strange, we&#8217;ve stored four letter tokens in <code>\l_mypkg_name_tl</code>.</p>
<p>As I said, a <code>tl</code> can contain anything: we are not limited to letters. So</p>
<pre>\tl_new:N \l_mypkg_other_tl
\tl_set:Nn \l_mypkg_other_tl { \ERROR ^ _ # $ ! }</pre>
<p>is also perfectly-valid for the content of a token list variable (although whether we&#8217;ll be able to use it safely is a different matter).</p>
<h2>Variable naming and TeX&#8217;s grouping system</h2>
<p>From the <a title="Programming LaTeX3: Creating functions" href="http://www.texdev.net/2011/12/14/programming-latex3-creating-functions/">earlier discussion</a> of the way that functions are named in LaTeX3, it might be obvious that there is also a system to how variables are named. Skipping over the initial&nbsp;<code>\l_</code>, what we&#8217;ve got is a module name (<code>mypkg</code>), some further description of the nature of the variable (in this case <code>name</code>), and finally the variable type (<code>tl</code>), divided up by <code>_</code> in exactly the same way we did for functions. We&#8217;ll see that other variables follow the same scheme.</p>
<p>So what&#8217;s the leading <code>\l_</code> about? This tells us about the <em>scope</em> that we should use when setting the variable. As TeX is a macro expansion language, variables are not local to functions. However, they can be local to TeX groups, which are created in LaTeX3 using</p>
<pre>
\group_begin:
% Code here
\group_end:
</pre>
<p>Setting a variable locally means that any changes stay within a group</p>
<pre>
\tl_new:N \l_mypkg_name_tl
\tl_set:Nn \l_mypkg_name_tl { Fred }
\group_begin:
  \tl_set:Nn \l_mypkg_name_tl { Ginger }
\group_end:
% \l_mypkg_name_tl reverts to 'Fred'
</pre>
<p>On the other hand, we sometimes need <em>global</em> variables which ignore any groups</p>
<pre>
\tl_new:N \g_mypkg_name_tl
\tl_gset:Nn \g_mypkg_name_tl { Fred }
\group_begin:
  \tl_gset:Nn \g_mypkg_name_tl { Ginger }
\group_end:
% \g_mypkg_name_tl still 'Ginger'
</pre>
<p>So the <code>\l_</code> or <code>\g_</code> tells you what scope the variable contents have, and whether you should <code>set</code> or <code>gset</code> it. (You can probably work out that <code>gset</code> means &#8216;set globally&#8217;.)</p>
<h2>Using the content of token list variables</h2>
<p>Okay, putting stuff into token list variables is all very well and good, but unless we can do something with the content then it&#8217;s not really that useful. Of course, we can do things with the content of variables. The most basic thing to do is simply to insert the content of the <code>tl</code> into the input that TeX is working with</p>
<pre>
\tl_use:N \l_mypkg_name_tl
</pre>
<p>That&#8217;s very handy, but we can also examine the content of a token list variable. For example, we saw before that <code>\tl_length:n</code> will produce the length of a token list, and we can do the same for a token list variable using <code>\tl_length:N</code>. </p>
<pre>
\tl_set:Nn \l_mypkg_name_tl { Fred }
\tl_length:N \l_mypkg_name_tl % '4'
</pre>
<p>There&#8217;s a lot more we can do with token list variables, but this post is already long enough, so I&#8217;ll come back to more that we can do with them in the next post.</p>
<h2>Tips for TeX programmers: the internals of token list variable</h2>
<p>Experienced TeX programmers are probably wondered about token list variables, and in particular exactly what the underlying TeX structure is. A <code>tl</code> is just a macro that we are using as a variable rather than function. That should not be too much of a surprise, as storing tokens in macros is very much basic TeX programming. So <code>\tl_set:Nn</code> is almost the same as the <code>\def</code> primitive.</p>
<p>What might worry you slightly is that I said</p>
<pre>\tl_new:N \l_mypkg_other_tl
\tl_set:Nn \l_mypkg_other_tl { \ERROR ^ _ # $ ! }</pre>
<p>will work. That won&#8217;t work with <code>\def</code>, and you&#8217;d normally expect to need a token register (<code>toks</code>) for this. However, we don&#8217;t use <code>toks</code> for LaTeX3 programming at all, and that&#8217;s because we require e-TeX. So</p>
<pre>\tl_set:Nn \l_mypkg_other_tl { \ERROR ^ _ # $ ! }</pre>
<p>is actually the same as</p>
<pre>\edef \l_mypkg_other_tl { \unexpanded { \ERROR ^ _ # $ ! } }</pre>
<p>which will allow us to put <em>any</em> tokens inside a macro.</p>
<p>The other thing you might notice is that I&#8217;ve said that <code>tl</code>s have to be declared, even though at a TeX level this is not the case. This is a principle of good LaTeX3 programming, and although it&#8217;s not enforced as standard any non-declared token list variables are coding errors. You can test for this using</p>
<pre>\usepackage[check-declarations]{expl3}</pre>
<p>which uses some slow checking code to make sure that all variables are declared before they are used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/12/26/programming-latex3-token-list-variables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming LaTeX3: Category codes, tokens and token lists</title>
		<link>http://www.texdev.net/2011/12/21/programming-latex3-category-codes-tokens-and-token-lists/</link>
		<comments>http://www.texdev.net/2011/12/21/programming-latex3-category-codes-tokens-and-token-lists/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 23:01:55 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>
		<category><![CDATA[Programming LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1230</guid>
		<description><![CDATA[Understanding LaTeX3 programming relies on understanding TeX concepts, and one we need to get to grips with is how TeX deals with tokens. Experienced TeX programmers will probably find the first part of this post very straight-forward, so might want to skim read the start! Category codes and tokens When TeX reads input, it is [...]]]></description>
			<content:encoded><![CDATA[<p>Understanding LaTeX3 programming relies on understanding TeX concepts, and one we need to get to grips with is how TeX deals with tokens. Experienced TeX programmers will probably find the first part of this post very straight-forward, so might want to skim read the start!</p>
<h2>Category codes and tokens</h2>
<p>When TeX reads input, it is not only the characters that are there that are important. Each character has an associated <em>category code</em>: a way to interpret that character. The combination of a character and it&#8217;s category code then sets how TeX will deal with the input. For example, when TeX read ‘<code>a</code>’ it finds that it&#8217;s (normally) a letter, and so tokenizes the input as ‘<code>a</code>, <code>letter</code>’. This seems pretty obvious: ‘a’ <em>is</em> a letter, after all. But this is not fixed, at least for TeX. I&#8217;ve already mentioned that within the LaTeX3 programming environment <code>:</code> and <code>_</code> can be part of function names: that&#8217;s because they are ‘letters’ while we are programming!</p>
<p>What&#8217;s of most importance now is that a control sequence (something like <code>\emph</code> or <code>\cs_new:Npn</code>) is stored as a single token. So most of the time it these can&#8217;t be divided up into their component characters: they act as a single item.</p>
<h2>Token lists</h2>
<p>The fact that TeX works with tokens means that most of the time we carry out operations on a token-by-token basis, rather than as strings. In LaTeX3  terminology, an arbitrary set of tokens is called a <em>token list</em>, and which of has both defined content and defined order.</p>
<p>To get a better feel for how token lists work, we&#8217;ll apply a few basic token list functions to some simple input:</p>
<pre>\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new:Npn \demo:n #1
  {
    \tl_length:n {#1} ;
    \tl_if_empty:nT {#1} { Empty! }
    \tl_if_blank:nTF {#1}
      { Blank! }
      {
        Head = \tl_head:n {#1} ;
        Tail = \tl_tail:n {#1} ;
        End
      }
  }
\cs_new_eq:NN \demo \demo:n
\ExplSyntaxOff
\newcommand*{\hello}{hello}
\begin{document}
\demo{Hello world}

\demo{ }

\demo{}

\demo{\hello}
\end{document}</pre>
<p>Okay, what&#8217;s going on here? Well, as we saw <a title="Programming LaTeX3: Creating functions" href="http://www.texdev.net/2011/12/14/programming-latex3-creating-functions/">last time</a> I&#8217;ve created a new function, in this case called <code>\demo:n</code>, which contains the code I want to use. In contrast to the last post, I&#8217;ve not used it directly but have instead used <code>\cs_new_eq:NN</code> to make a copy of this function but with a document-level name. This is a general LaTeX3 idea: the internals of your code should be defined separately from the interface (indeed, we&#8217;ll see later that there is a more formalised way of creating a document-level function). You can probably work out that <code>\cs_new_eq:NN</code> needs two arguments: the new function to create and the old one to copy. (For experienced TeX programmers, it will be no surprise that this is a wrapper around the <code>\let</code> primitive.)</p>
<p>Moving on to what <code>\demo:n</code> is doing, the first thing to see is that I&#8217;ve defined it with one argument, agreeing with the <code>:n</code> part of its name. I&#8217;ve then done some simple tests on the argument. The first is <code>\tl_length:n</code>, which will count how many tokens are in the input and simply output the result. You&#8217;ll notice that it&#8217;s ignored the space in <code>Hello world</code>: it&#8217;s a common feature of TeX that spaces are often skipped over. You can also see the space-skipping behaviour in the line where I feed <code>\demo</code> a space: the result has a ‘length’ of zero. Also notice that as promised <code>\hello</code> is only a single token. (There is an experimental function in LaTeX3 to count the length of a token list <em>including</em> the spaces. Most of the time, we&#8217;ll actually want to ignore them so we won&#8217;t worry about that here!)</p>
<p>We then have to <em>conditionals</em>, <code>\tl_if_empty:nT</code> and <code>\tl_if_blank:nTF</code>. First, we&#8217;ll look at what a conditional does in general, then at these two in particular. The LaTeX3 approach to conditionals is to accept either one or two arguments, which might read <code>T</code>, <code>F</code> or <code>TF</code>, so in general there are always three related functions:</p>
<pre>  \foo_if_something:nT
  \foo_if_something:nF
  \foo_if_something:nTF</pre>
<p>The test is always the same for the three related versions, with the <code>T</code> and <code>F</code> part tells us what code is used depending on the result of the test. So if we do a test and it&#8217;s true, the <code>T</code> code will be used if it&#8217;s there, and the <code>F</code> code will be skipped entirely, while if there is no <code>T</code> code then nothing happens. It&#8217;s of course the other way around when the test is false!</p>
<p>So what&#8217;s happening with <code>\tl_if_empty:nT</code> and <code>\tl_if_blank:nTF</code>? In the first test, we only print <code>{ Empty! }</code> if there is nothing <em>at all</em> in the argument to <code>\demo:n</code>. If the argument is no empty, then this test does nothing at all. On the other hand, the <code>\tl_if_blank:nTF</code> test will print <code>{ Blank! }</code> if the argument is either entirely empty or is only made up of spaces (so it looks blank). However, if it&#8217;s not blank then we apply two more functions.</p>
<p>The functions <code>\tl_head:n</code> and <code>\tl_tail:n</code> find the very first token and everything but the very first token, respectively. So <code>\tl_head:n</code> finds just the <code>H</code> of <code>Hello world</code> while <code>\tl_tail:n</code> finds <code>ello world</code>. I&#8217;ve only used them if the entire argument is not blank as they are not really designed to deal with cases where there is nothing to split up! You might wonder about the last test, where <code>\demo{\hello}</code> has <code>Hello</code> as the head part and nothing as the tail. That happens because what is tested here is <code>\hello</code>, a single token, which is then turned into the text we see by TeX during typesetting. That can be avoided, but at this stage we&#8217;ll not worry too much!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/12/21/programming-latex3-category-codes-tokens-and-token-lists/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Programming LaTeX3: Creating functions</title>
		<link>http://www.texdev.net/2011/12/14/programming-latex3-creating-functions/</link>
		<comments>http://www.texdev.net/2011/12/14/programming-latex3-creating-functions/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 21:38:15 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>
		<category><![CDATA[Programming LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1216</guid>
		<description><![CDATA[Teaching a programming language traditionally starts with a method to print ‘Hello World’. For programming LaTeX3, we can&#8217;t quite start there as \documentclass{article} \begin{document} Hello world \end{document} will happily do that without needing any programming. So I&#8217;ll start by printing ‘Hello World’ lots of times! Our first function LaTeX3 has a built-in method for creating [...]]]></description>
			<content:encoded><![CDATA[<p>Teaching a programming language traditionally starts with a method to print ‘Hello World’. For programming LaTeX3, we can&#8217;t quite start there as</p>
<pre>\documentclass{article}
\begin{document}
Hello world
\end{document}</pre>
<p>will happily do that without needing any programming. So I&#8217;ll start by printing ‘Hello World’ <em>lots</em> of times!</p>
<h2>Our first function</h2>
<p>LaTeX3 has a built-in method for creating multiple copies of text, which we could use directly. However, that would mean using a code-level macro in the document itself, and so I&#8217;ll create a wrapper macro. For this first example, I&#8217;ll include all of the document:</p>
<pre>\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new:Npn \SayHello #1
  { \prg_replicate:nn {#1} { Hello~World!~ } }
\ExplSyntaxOff
\begin{document}
\SayHello{100}
\end{document}</pre>
<p>This will give you, as promised, 100 copies of ‘Hello World!’.</p>
<p>So what is going on here? As you might work out, I&#8217;ve defined a new command called <code>\SayHello</code> which prints as many copies of ‘Hello World!’ as requested. Later on we&#8217;ll see that this is usually not how I&#8217;d choose to create a ‘document command’, but for the moment I&#8217;ll pass over that point so we can get some basics established.</p>
<h2>The structure of function names</h2>
<p>Getting down to detail, I&#8217;ve introduced two LaTeX3 functions here: <code>\cs_new:Npn</code> and <code>\prg_replicate:nn</code>. <a title="Programming LaTeX3: The programming environment" href="http://www.texdev.net/2011/12/11/programming-latex3-the-programming-environment/">As promised</a>, these use <code>:</code> and <code>_</code> as ‘letters’ in their names. But what do they do? As you might guess from the names, <code>\cs_new:Npn</code> is used to create a new control sequence, while <code>\prg_replicate:nn</code> makes lots of copies of something (it replicates stuff). The naming convention for LaTeX3 is that the first part of the name (<code>\cs_…</code> or <code>\prg_…</code>) refers to the <em>module</em> the function comes from. So <code>\cs_new:Npn</code> is from the module for control sequences, which we abbreviate as <code>cs</code>, while <code>\prg_replicate:nn</code> is from the general programming utilities module, which is abbreviated as <code>prg</code>. For programmers working outside of the LaTeX3 kernel, a module is probably going to be the same as a LaTeX2e package. So the module part of the name is used to divide up code into related blocks: each module should use a unique prefix, and I&#8217;ll tend to use <code>\mypkg…</code> for demonstration purposes.</p>
<p>Up to the <code>:</code>, the rest of the name is up to the programmer and should help you understand what a function does. So <code>\cs_new:Npn</code> tells us that the function makes new a control sequence, and so is pretty similar to LaTeX2e&#8217;s <code>\newcommand</code>. We can have multiple parts to the name divided by <code>_</code> for ease of reading. For example <code>\cs_new_nopar:Npn</code> is available for creating new functions which will give an error if they pick up a <code>\par</code>: this is similar to <code>\newcommand*</code>. You can probably work out the analysis of <code>\prg_replicate:nn</code> yourself!</p>
<p>The part of the name after the <code>:</code> is perhaps one of the most confusing ideas for new LaTeX3 programmer, especially if they are used to other languages. It&#8217;s called the <em>argument specification</em> or <em>signature</em> of the function, and tells us about the number and type of arguments a function takes. If you have experience in other programming languages, you&#8217;re probably wondering why we include this information in the function name. As we&#8217;ll see as we look in more detail at LaTeX3, this approach works as it reflects how TeX works.</p>
<p>So what do the different letters mean? Each letter (usually) represents one argument for a function. So <code>\prg_replicate:nn</code> with two letters after the <code>:</code> needs two arguments. (For those of you who haven&#8217;t come across arguments before, something like <code>\maketitle</code> takes no arguments, <code>\emph</code> needs one argument, <code>\setlength</code> takes two arguments, and so on.) The letter itself then tells us about the type of argument: <code>n</code> means tokens in braces (a ‘normal’ argument).  In <code>\cs_new:Npn</code>, the <code>n</code>-type argument is the code which we are creating. An <code>N</code> means that the argument has to be a single token <em>without</em> any braces: in our current case this will be the name of the new function. The <code>p</code> is a bit more complicated: it means that the second argument here is a parameter specification. Here, we can use <code>#1</code>, <code>#2</code>, <em>etc.</em>, to represent the arguments for the new function, in exactly the same way we do in the code. So when we use <code>\SayHello</code>, it will expect to find one argument, and will insert that into the place marked as <code>#1</code> in the code part.</p>
<h2>Analysis <code>\prg_replicate:nn</code></h2>
<p>The same analysis applies to <code>\prg_replicate:nn</code>, which we can now see needs two arguments, both in braces. The first one is the number of times to repeat, and the second argument is what to repeat. So in <code>\SayHello</code> the number of repetitions is supplied by the user (this will  replace <code>#1</code>), but the text is fixed by the programmer.</p>
<p>The reference for finding out what functions are available, and what arguments they take, is <a href="http://mirror.ctan.org/macros/latex/contrib/l3kernel/interface3.pdf">interface3</a>. I&#8217;ll only be covering a selection of what is available, so over time you&#8217;ll need to get familiar with the formal documentation to find out what you can do. If you take a look there, you&#8217;ll see that the first argument for <code>\prg_replicate:nn</code> is an <em>integer expression</em>. That means that we don&#8217;t have to use a number directly here, but can also use something that will result in a number once TeX has worked it out. That will carry through to our user function, so</p>
<pre>
\SayHello{ 10 - 3 + 4 }
</pre>
<p>will be valid input.</p>
<h2>Functions or macros?</h2>
<p>Experienced TeX programmers will probably be worried that I&#8217;m talking about ‘functions’ and not about ‘macros’. TeX is a macro expansion language, which means that when it reads <code>\SayHello</code>, it replaces it by the code we&#8217;ve defined as the meaning of <code>\SayHello</code>, then reads the start of the inserted code, replaces it as necessary and so on until it has something to typeset (such as a letter) or execute (a ‘primitive’). That means that programming TeX is very different from programming using true functions.</p>
<p>The LaTeX3 programming approach allows us to treat many macros as if they were functions, but there are places where we&#8217;ll need to think about macros being expanded. Throughout the LaTeX3 documentation, programming is described in terms of functions, and so I&#8217;ll stick to that approach. Bear in mind that underlying everything is a set of macros, and that this will show up from time to time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/12/14/programming-latex3-creating-functions/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Programming LaTeX3: The programming environment</title>
		<link>http://www.texdev.net/2011/12/11/programming-latex3-the-programming-environment/</link>
		<comments>http://www.texdev.net/2011/12/11/programming-latex3-the-programming-environment/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 18:01:02 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>
		<category><![CDATA[Programming LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1206</guid>
		<description><![CDATA[In the previous post, I mentioned that programming LaTeX3 today really means programming using LaTeX3 ideas but on top of LaTeX2e. To do that, we are going to need to load the appropriate code, and then access the LaTeX3 programming environment. The exact detail depends on whether we are programming in the preamble of a [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a title="Programming LaTeX3: Background" href="http://www.texdev.net/2011/12/07/programming-latex3-background/">previous post,</a> I mentioned that programming LaTeX3 today really means programming using LaTeX3 ideas but on top of LaTeX2e. To do that, we are going to need to load the appropriate code, and then access the LaTeX3 programming environment. The exact detail depends on whether we are programming in the preamble of a LaTeX document or creating a package. I&#8217;ll look at both of these before taking a closer look at the LaTeX3 programming environment in general.  What you should notice is that the use of a separate programming environment very much separates out the process of creating code from creating documents: that is quite deliberate and is something that we&#8217;ll see again in the series.</p>
<h2>In the preamble of a document</h2>
<p>The LaTeX3 programming code usable with LaTeX2e is available as a package called expl3 (which for various reasons is distributed as part of <a href="http://ctan.org/pkg/l3kernel">l3kernel</a>). This is loaded in the usual way</p>
<pre>\documentclass{article}
\usepackage{expl3}</pre>
<p>That loads the code, but does not get us into the programming environment. To do that, we need to use a couple of new macros</p>
<pre>\ExplSyntaxOn
% Code goes here
\ExplSyntaxOff</pre>
<p>In some ways, this is similar to the LaTeX2e <code>\makeatletter</code> … <code>\makeatother</code> idea, but as we&#8217;ll see it&#8217;s a bit more advanced.</p>
<h2>In a LaTeX2e package</h2>
<p>In exactly the same way as in a document, the first stage in using LaTeX3 programming in a package is to load the code.</p>
<pre>\RequirePackage{expl3}</pre>
<p>Once again, that loads the code but does not switch the syntax on. We could use <code>\ExplSyntaxOn</code> here, but for packages a more flexible alternative is to declare the package as being LaTeX3-based:</p>
<pre>\ProvidesExplPackage
  {mypkg}               % Package name
  {2011-12-11}          % Release date
  {1.0}                 % Release version
  {Some things I wrote} % Description</pre>
<p>This is a special version of the standard <code>\ProvidesPackage</code> macro, which will automatically turn on LaTeX3 programming syntax and more importantly turn it off at the end of the package. It also deals properly with nested package loading, and so is the recommended way to use LaTeX3 syntax inside LaTeX2e packages.</p>
<h2>The coding environment</h2>
<p>Whether you&#8217;re using LaTeX3 syntax in a document or a package, the basic ideas are the same. The first thing to notice is that white space (spaces, tabs and new lines) are ignored inside the programming environment. This means we can use it to lay out our code more clearly, but you might wonder how to actually include a space. This is handled by defining <code>~</code> as a ‘normal’ space, rather than as the usual non-breaking version.</p>
<p>The programming environment also makes it possible to use <code>:</code> and <code>_</code> inside the names of commands, which are more formally called <em>control sequences</em>. TeX decides what is a valid control sequence name based on something called the <em>category code</em> of each character. I&#8217;ll be explaining more about category code as we go along, but for the moment the key is to understand that that a control sequence is <code>\</code> followed either by exactly one non-‘letter’ or by one or more ‘letters’. Inside the code environment <code>:</code> and <code>_</code> are treated as letters by TeX: this is the same idea as using <code>@</code> as an extra ‘letter’ in LaTeX2e code.</p>
<p>Not only are <code>:</code> and <code>_</code> available for use in control sequences but they are required by the conventions of LaTeX3 programming. In contrast to LaTeX2e&#8217;s sometimes haphazard use of <code>@</code> in names, there are guidelines for applying both <code>:</code> and <code>_</code> in LaTeX3 names. Rather than give a formal list now, I&#8217;ll bring in the system in the next couple of posts using some examples.</p>
<p>One difference between programming in a document and in a package is the status of <code>@</code>. LaTeX2e automatically makes it a letter in package code, but in a document this does not happen. LaTeX3 does not assign any special meaning to <code>@</code>, and so these difference are not affected by loading LaTeX3 support.</p>
<h2>A standard document</h2>
<p>As we&#8217;ll be needing the basics here for everything from now on, I&#8217;ll assume that you are using a short testing document for LaTeX3 programming:</p>
<pre>\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
% Code will go here
\ExplSyntaxOff
\begin{document}
\end{document}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/12/11/programming-latex3-the-programming-environment/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Programming LaTeX3: Background</title>
		<link>http://www.texdev.net/2011/12/07/programming-latex3-background/</link>
		<comments>http://www.texdev.net/2011/12/07/programming-latex3-background/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 22:14:22 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>
		<category><![CDATA[Programming LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1201</guid>
		<description><![CDATA[Before the series on programming LaTeX3 can really get started, it&#8217;s going to be important to establish some background, basic concepts and indeed what the aims are. So in this post I&#8217;m going cover some of these issues: we won&#8217;t be seeing any code just yet! The approach I&#8217;m aiming to take is to bring [...]]]></description>
			<content:encoded><![CDATA[<p>Before the <a title="Programming LaTeX3: Introduction" href="http://www.texdev.net/2011/12/06/programming-latex3-introduction/">series on programming LaTeX3</a> can really get started, it&#8217;s going to be important to establish some background, basic concepts and indeed what the aims are. So in this post I&#8217;m going cover some of these issues: we won&#8217;t be seeing any code just yet! The approach I&#8217;m aiming to take is to bring in concepts as they are needed: this may mean a few simplifications in the beginning to allow ideas to be developed.</p>
<h2>LaTeX3: What is available now?</h2>
<p>The very first thing to cover is what the current status of LaTeX3 is, and what the aim of this series is. Anyone following LaTeX3 development will know that at the moment it&#8217;s not ready for creating documents independent of LaTeX2e. What is available now is a programming layer: <a href="http://ctan.org/pkg/l3kernel">l3kernel</a>. At the same time, one of the aims with LaTeX3 is to clearly separate out programming, design decisions and actually using LaTeX. So what I will be covering here is programming. At the same time, I&#8217;ll aim to highlight concepts which are not necessarily tied to LaTeX3 programming but which the LaTeX3 Project feel are part of the overall aims of LaTeX3 development.</p>
<h2>The target audience</h2>
<p>I have two distinct audiences in mind in writing this series. The first is experienced (La)TeX programmers who want to see what ideas LaTeX3 introduces. These people will be familiar with many basic TeX concepts, and will want to see the relationship between what they are used to and the ‘LaTeX3 way’. The second group is experience LaTeX2e users who want to learn to program LaTeX, and have decided to miss out learning to program TeX first. It&#8217;s important that the latter group are included: another key aim for LaTeX3 is to provide a complete set of documentation and support without having to say ‘read <em>The TeXbook</em>’ as a requirement to make progress.</p>
<p>What both of these groups have in common is lots of experience with LaTeX2e. So I&#8217;m going to expect familiarity with LaTeX2e&#8217;s user syntax, concepts and so on. So that will very much be the baseline: I do hope that the more experienced LaTeX programmers will bear with me.</p>
<h2>Requirements</h2>
<p>As I&#8217;ve indicated, programming LaTeX3 currently means works on top of LaTeX2e. So to get started you need a LaTeX2e installation, which for most people means either <a href="http://tug.org/texlive">TeX Live</a> or <a href="http://www.miktex.org/">MiKTeX</a>. Most of the code in the programming layer of LaTeX3 has been moving to a stable situation for some time, but there are refinements going on all of the time. As a result, I&#8217;ll be assuming that readers have the latest <a href="http://www.ctan.org/">CTAN</a> releases of <a href="http://ctan.org/pkg/l3kernel">l3kernel</a> and <a href="http://ctan.org/pkg/l3packages">l3packages</a> installed. That can be done by downloading them from CTAN directly, or using the package managers in TeX Live 2011 or MiKTeX 2.9.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/12/07/programming-latex3-background/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming LaTeX3: Introduction</title>
		<link>http://www.texdev.net/2011/12/06/programming-latex3-introduction/</link>
		<comments>http://www.texdev.net/2011/12/06/programming-latex3-introduction/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 22:00:28 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>
		<category><![CDATA[Programming LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1196</guid>
		<description><![CDATA[Development of LaTeX3 has attracted interest from other TeX programmers for a while. One of the big barriers to new entrants is that programming LaTeX3 is distinct from programming LaTeX2e or plain TeX. So what is needed is a ‘Programming LaTeX3’ guide. The problem is getting one written: these things take time, and what to [...]]]></description>
			<content:encoded><![CDATA[<p>Development of LaTeX3 has attracted interest from other TeX programmers for a while. One of the big barriers to new entrants is that programming LaTeX3 is distinct from programming LaTeX2e or plain TeX. So what is needed is a ‘Programming LaTeX3’ guide. The problem is getting one written: these things take time, and what to write is also something of a challenge.</p>
<p>To make a start on tackling this, I thought it would be useful to write a series of short blog posts, taking one area of LaTeX3 at a time and looking at it from the point of view of beginner in programming LaTeX3. The idea is that by keeping things short I can divide the problem into manageable chunks (both for readers and for me), and get feedback on each part before taking on the next one. If I make decent progress, I&#8217;ll then have some material to edit into something like an article for <a href="http://tug.org/tugboat"><em>TUGBoat</em></a>.</p>
<p>Now, to do a reasonable job I will have to cover some things I&#8217;ve looked at before: sorry if it turns out to be repetitive in places. I&#8217;m planning to start by looking at how you can actually start programming LaTeX3 today, covering the idea of ‘LaTeX3 in 2e’, for example. Then it will be on to the basics of the language, before we even get to creating any macros. Ideas for topics to cover are very welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/12/06/programming-latex3-introduction/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Font schemes and LaTeX3</title>
		<link>http://www.texdev.net/2011/11/27/font-schemes-and-latex3/</link>
		<comments>http://www.texdev.net/2011/11/27/font-schemes-and-latex3/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 11:48:43 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[NFSS]]></category>
		<category><![CDATA[OpenType]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1185</guid>
		<description><![CDATA[There was a question recently on the TeX.sx site about font selection and LaTeX3. At the moment, there is not a LaTeX3 font system set up, and there are issues outstanding, so this is not something with a single answer. What I can do, though, is look at what seems likely and what some of [...]]]></description>
			<content:encoded><![CDATA[<p>There was a <a href="http://tex.stackexchange.com/q/36112/73">question recently</a> on the <a href="http://tex.stackexchange.com/">TeX.sx</a> site about font selection and LaTeX3. At the moment, there is not a LaTeX3 font system set up, and there are issues outstanding, so this is not something with a single answer. What I can do, though, is look at what seems likely and what some of the areas to consider are.</p>
<h2>(New) Font Selection Scheme</h2>
<p>TeX&#8217;s font mechanism is pretty basic. There is no relationship between one text font and another: they are all simply set up using the <code>\font</code> primitive. So with plain TeX</p>
<pre>{\bf Some {\it text}}</pre>
<p>will have ‘Some’ in bold, but ‘text’ in mid-weight italics. LaTeX2e introduced the ‘New Font Selection Scheme’ (NFSS), which provides a method for managing fonts in a way that is likely to be more logical for the user. Thus</p>
<pre>{\bfseries Some {\itshape text}}</pre>
<p>will have the inner text both bold and italic. At the same time, the NFSS provides a system for loading font files in an organised way and substituting fonts when a particular shape combination is unavailable.</p>
<p>Over all, the NFSS is one the key successes of LaTeX2e compared with LaTeX2.09. There are also a lot of existing <code>.fd</code> files about for using fonts with LaTeX2e, and supporting those is important. So something like the NFSS is definitely needed: the ‘New’ is rather anachronistic nowadays, so the working title is just FSS.</p>
<p>The NFSS is not perfect, and so LaTeX3&#8242;s FSS cannot be simply a clone of NFSS. Perhaps the most common complaint about the NFSS is that <code>\textsc</code> is treated as a shape, which makes it impossible to combine it with <code>\itshape</code> to have italic small caps. Other areas which need addressing are for example flexible sizing and proportional/fixed width numbers for tables. This is all evolutionary, and so the plan is to port the existing NFSS first, tidy it up to fit better with LaTeX3 coding approaches, then add new abilities.</p>
<h2>Font face loading</h2>
<p>The second area to think about is loading fonts in the first place. The traditional LaTeX2e approach to this to set up a small(ish) package to select a font family, for example <a href="http://ctan.org/pkg/lmodern">lmodern</a> or <a href="http://ctan.org/pkg/mathptmx">mathptmx</a>, which will then use the NFSS to load the appropriate TeX font files. For users of XeTeX or LuaTeX, the standard method is to use the <a href="http://ctan.org/pkg/fontspec">fontspec</a> package, which provides an interface between the extended <code>\font</code> primitives in these engines and the NFSS.</p>
<p>There are a few things to think about here. First, while XeTeX and LuaTeX can load system fonts directly, pdfTeX cannot. Secondly, even if you are using XeTeX or LuaTeX access to traditional TeX fonts cannot be ignored. There is a lot of MetaFont material on CTAN which is not available in any other format, so simply dropping support for these is not an option.</p>
<p>What I feel we need is a single font-loading interface at the user level which is capable of dealing with these requirements. Clearly, fontspec is going to provide inspiration on how to proceed, but some mechanism for working with pdfTeX will also be needed. My personal take on this is we&#8217;ll need a mapping layer, which will mean that at the user level you choose a font by name (as you would in a GUI application), and which then does the appropriate translation to the engine layer.</p>
<p>There are also math mode fonts to worry about. OpenType maths fonts are very much in development, but that doesn&#8217;t help with pdfTeX and again does not cover all cases. So again we need to continue to support TeX&#8217;s traditional math mode fonts. That will probably be the last part of this particular jigsaw to be tackled, simply because it&#8217;s the one with the least clear path at present.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/11/27/font-schemes-and-latex3/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>LaTeX3 Roadmap</title>
		<link>http://www.texdev.net/2011/09/05/latex3-roadmap/</link>
		<comments>http://www.texdev.net/2011/09/05/latex3-roadmap/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 08:45:17 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1094</guid>
		<description><![CDATA[One of the questions that comes up from time to time is what the ‘roadmap’ is for LaTeX3 development. While there is not an official plan, I certainly have some ideas on what I&#8217;d like to see addressed in a concrete way. This is all rather flexible, but I&#8217;ll try to outline some areas for [...]]]></description>
			<content:encoded><![CDATA[<p>One of the questions that <a title="LaTeX3: More use, more work" href="http://www.texdev.net/2011/09/01/latex3-more-use-more-work/">comes up from time to time</a> is what the ‘roadmap’ is for LaTeX3 development. While there is not an official plan, I certainly have some ideas on what I&#8217;d like to see addressed in a concrete way. This is all rather flexible, but I&#8217;ll try to outline some areas for attention.</p>
<h2>Short term</h2>
<p>The short term is about things which LaTeX3 does not critically depend on, and for which a lot of work is already done. This is very much an ongoing area:  small improvements spread across a range of topics. These items all fit into the concept of ‘LaTeX3 in LaTeX2e’, where this material can be loaded without affecting existing documents.</p>
<h3>Floating point expressions</h3>
<p>The current floating point implementation in LaTeX3 is based on carrying out assignments, and is pretty simple-minded in the way values are stored. Bruno Le Floch is working on an <a href="https://github.com/latex3/svn-mirror/tree/master/l3trial/l3fp-new">improved approach</a>, which will allow floating point expressions to be parsed in an expandable way. This will be very handy for doing things like box rotations, but also in the future for <a href="http://ctan.org/pkg/pgf">Tikz</a>-like drawing capabilities.</p>
<h3>Extending key–value concepts</h3>
<p>The current <a href="https://github.com/latex3/svn-mirror/blob/master/l3kernel/l3keys.dtx">l3keys</a> module is based loosely on <a href="http://ctan.org/pkg/pgf">pgfkeys</a>. One area that is not implemented is the idea of a ‘key path’. Using a path model for setting keys has some advantages, so I&#8217;d like to add something like the ability to do</p>
<pre>\keys_set:n
  {
    /module .cd ,
    key-a = value ,
    key-b .meta = { key-a = setting , /other-module/key = value }
  }</pre>
<h3>LaTeX3 niggles</h3>
<p>There are a <a href="https://github.com/latex3/svn-mirror/issues?sort=created&amp;direction=desc&amp;state=open">number of issues</a> that have come up as LaTeX3 has seen more use. Fixing these is an ongoing problem, and we should probably look to deal with a few over the coming weeks. The supply is not going to run out!</p>
<h3>Documentation improvements</h3>
<p>A key aim for LaTeX3 is to document all of the material which is intended for others to use. Getting documentation right is hard, and so another ongoing area is to improve the documentation. We&#8217;ve already done a bit of work on this, but it&#8217;s certainly not complete.</p>
<h2>Medium term</h2>
<p>The medium term is about bigger ideas, but ones where there is some code written and we can see that results will appear within the next few months. These areas need discussion as much as writing code. Here, we move away from ‘LaTeX3 in LaTeX2e’ to code which will break existing documents unless they are adapted.</p>
<h3>The galley</h3>
<p>The galley is the vertical area into which text and other content is places. Galley management in LaTeX2e is basic, and this leads to odd effects with vertical spacing. For example, try</p>
<pre>\end{itemize}
\vspace{3 pt}
\begin{itemize}</pre>
<p>and see that you get 12 pt of space! We&#8217;ve already got three galley implementations, and are now working on a fourth! So the issue here is deciding what is the best approach: the different versions all have different levels of complexity. Hopefully we can resolve these ideas into a single working module within the next couple of months.</p>
<h3>Font selection</h3>
<p>The ‘New Font Selection Scheme’ in LaTeX2e is a pretty good approach to selecting fonts. So the first task here is more-or-less to convert the code to LaTeX3 syntax. There are then a few items to address, such as how to deal with small caps. Loading fonts also needs to be fitted in here: some combination of <a href="http://ctan.org/pkg/fontspec">fontspec</a> (for XeTeX and LuaTeX) with the existing pdfTeX mechanisms is going to be needed, and it&#8217;s a question of how to do this.</p>
<h2>Long term</h2>
<p>The long-term is again about big ideas, but here ones where the code is not yet written. Some of the concepts are sorted, but beyond that there is work to do.</p>
<h3>The output routine</h3>
<p>The biggest single challenge for LaTeX3 at an implementation level is getting the output routine right. Here, we have <a href="https://github.com/latex3/svn-mirror/tree/master/xpackages/xor">xor</a>, an approach written by Frank Mittelbach. This works, but it&#8217;s in need of a serious overhaul as the code has developed over many years. So at the moment it&#8217;s rather a mix of LaTeX2e and LaTeX3 stuff. We&#8217;ve also got to discuss how the output routine should work, addressing things like flowing text across frames, grid typesetting and so on. This is all hard work.</p>
<h3>Beyond the output routine</h3>
<p>Once we have all of the above addressed, then we need to look at getting a format created that can actually typeset material. That means building the code level, galley, fonts and output routine into a stand-alone format. The result won&#8217;t be impressive, as it won&#8217;t have much in the way of mark-up abilities. However, it will allow testing without LaTeX2e. That&#8217;s the stage where we&#8217;ll need to add things like sectioning, float management, and all of the other stuff that can be done by LaTeX at the moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/09/05/latex3-roadmap/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>LaTeX3: More use, more work</title>
		<link>http://www.texdev.net/2011/09/01/latex3-more-use-more-work/</link>
		<comments>http://www.texdev.net/2011/09/01/latex3-more-use-more-work/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 19:47:34 +0000</pubDate>
		<dc:creator>Joseph Wright</dc:creator>
				<category><![CDATA[LaTeX3]]></category>

		<guid isPermaLink="false">http://www.texdev.net/?p=1090</guid>
		<description><![CDATA[In the latest LaTeX3 News, the Project announced that a mirror of the development code is available on GitHub. Since then, there has been a definite increase in using expl3 (the LaTeX3 programming language), and we&#8217;ve had a number of very good questions on the LaTeX3 mailing list. The programming layer of LaTeX3 works well [...]]]></description>
			<content:encoded><![CDATA[<p>In the latest <a href="http://www.latex-project.org/site-news.html#2011-08-09">LaTeX3 News</a>, the <a href="http://www.latex-project.org/">Project</a> announced that a <a href="https://github.com/latex3/svn-mirror">mirror of the development code</a> is available on <a href="http://github.com/">GitHub</a>. Since then, there has been a definite increase in using expl3 (the LaTeX3 programming language), and we&#8217;ve had a number of very good questions on the <a href="http://news.gmane.org/group/gmane.comp.tex.latex.latex3">LaTeX3 mailing list</a>.</p>
<p>The programming layer of LaTeX3 works well in the main, and so it&#8217;s very pleasing to see other people starting to pick up on using it. Of course, there are some rough edges, and one result of the questions is that these have to be addressed. At the same time, wider use means that there is a greater need to make sure that the code is stable enough. Getting the balance right between making desirable changes and ensuring that other peoples code does not break is not easy! So there is more work to do with greater use.</p>
<p>At the same time, there is the question of a wider ‘road map’. For the programming layer, there are a few outstanding issues, for example a broader string module and an expandable floating point unit (both under way). However, most of the ‘big issues’ are outside of the base layer: we need support for a new format. There&#8217;s quite a lot to talk about there, and I&#8217;ll come back to it in another post in a day or so.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.texdev.net/2011/09/01/latex3-more-use-more-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

