[XeTeX] Automate table creation

Bruno Le Floch blflatex at gmail.com
Thu Mar 1 15:07:15 CET 2012


As Tobias mentions, use a package for loops. I think the code below
should work, but I don't know how to build diacritics on a letter:
isn't the point of combining marks that just putting the two
characters next to each other should do the trick? I didn't test.

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\DeclareDocumentCommand{\maketable}{mm}
  {
    \use:x { \noexpand\begin{tabular}{*{\clist_length:n{#2}}} }
    \clist_map_inline:nn {#2} { & ##1 }
    \clist_map_inline:nn {#1}
      {
         \\
         ##1
         \clist_map_inline:nn {#2}
            { & \build_diacritic:nn {##1} {####1} }
      }
    \end{tabular}
  }
\cs_new_protected:Npn \build_diacritic:nn #1#2 {#1#2} % dunno?
\ExplSyntaxOff
\begin{document}
\maketable{^,`}{a,b,c}
\end{document}

On 3/1/12, Tobias Schoel <liesdiedatei at googlemail.com> wrote:
> Look for looping packages, e.g. multido and pgffor. pgffor's foreach
> command seems to be quite suitable, except I haven't yet made it work
> inside tabulars.
>
> On 01.03.2012 04:27, Aleksandr Andreev wrote:
>> Hello everybody,
>>
>> I am wondering if someone could guide me as to how to create a macro
>> in XeTeX that will do the following.
>>
>> Background: I'm creating some files that demonstrate whether or not
>> OpenType features are correctly implemented in a font (for now, I am
>> only concerned with the correct positioning of diacritics). For this,
>> I would like to create a set of tables.
>> Across the columns of the table, I will have the diacritic marks; for
>> illustrative purposes, let's say they are U+0300, U+0301 and U+0311,
>> etc. (the actual file will have about 20 such marks)
>>
>> Down the rows, I am putting characters, say U+0410 (Cyrillic A),
>> U+0415 (Cyrillic Ie), etc, about 50 total, not necessarily contiguous
>> within Unicode.
>>
>> In each cell of the Table, all I need is to combine the character and
>> the diacritic.
>>
>> So, for example, I'll have:
>>
>> begin{tabular}
>>   &  ̀&  ́ \\
>> A&  À&  Á \\
>> etc.
>>
>> Here's the question: is there any way to write a TeX macro to build
>> this table automatically -- i.e., I feed it the list of characters and
>> diacritics, and it creates the Table? Basically, I'm being lazy and
>> not wanting to type out the entire 50x20 table.
>>
>> Thanks!
>>
>> Aleksandr



More information about the XeTeX mailing list