3

This question is in followup to this question; an excellent response there has allowed me to very easily make tables for examples in the grammar book I am working on which have one language on one row, and the corresponding translation on the following row. For example, the following example is produced by the code underneath it:

enter image description here

\begin{ExampleRow}
\dakota{čhaŋté + oyúze,   čhaŋtóyuze,    čhaŋté + ohnáka,  čhaŋtóhnaka}
\english{heart + condition of,  disposition,    heart + to place inside,    to cherish}
\gap 
\dakota{ȟe + o + púza, ȟópuza,    napé + ožáža  ,napóžaža}
\english{mountain+ place + dry, desert, hand + washing place,   sink}
\end{ExampleRow}

Such a method of quickly producing tables which are uniform in style has been very helpful; and I have been trying to take what I have learned since asking the last question and apply it to make a similar command for producing tables which function similarly (i.e. you need not specify the number of rows or columns beforehand) but instead are transposed, with words of the same language / font appearing in columns instead of rows.

More specifically, I am looking to create a command ExampleCol which, when given the following input,

\begin{ExampleCol}
\dakota{čhaŋté + oyúze,   čhaŋtóyuze,    čhaŋté + ohnáka,  čhaŋtóhnaka}
\english{heart + condition of,  disposition,    heart + to place inside,    to cherish} 
\end{ExampleCol}

Would produce the following table:

enter image description here

I'll try my best to summarize what I have so far: here is a minimal working example for the first table (which inputs by rows)

\documentclass{memoir}
\usepackage{fontspec}
\usepackage{booktabs}
\usepackage{etoolbox}

\newfontfamily\dak{Linux Biolinum O}
\newfontfamily\eng{JosefinSans-SemiBold}

\renewcommand{\arraystretch}{1.2}
\newcommand{\gap}{\\[-1.2ex]}

\newcommand{\doenglish}[1]{\appto\temp{&\eng{#1}}}
\newcommand{\dodakota}[1]{\appto\temp{&\dak{#1}}}

\newcommand{\english}[1]{%
\def\temp{}% initialize to empty
\forcsvlist{\doenglish}{#1}% add entries
\appto\temp{\\}% end the row
\temp % deliver contents
}

\newcommand{\dakota}[1]{%
\def\temp{}% initialize to empty
\forcsvlist{\dodakota}{ #1}% add entries
\appto\temp{\\}% end the row
\temp % deliver contents
}

\newenvironment{ExampleRow}
{\begin{center}
\begin{tabular}{ c@{} *{\maxcolumns}{c} } \toprule
{\bottomrule\end{tabular}
\end{center}}

\def\maxcolumns{20}


\begin{document}
\begin{ExampleRow}
\dakota{čhaŋté + oyúze,   čhaŋtóyuze,    čhaŋté + ohnáka,  čhaŋtóhnaka}
\english{heart + condition of,  disposition,    heart + to place inside,    to cherish}
\gap 
\dakota{ȟe + o + púza, ȟópuza,    napé + ožáža  ,napóžaža}
\english{mountain+ place + dry, desert, hand + washing place,   sink}
\end{ExampleRow}
\end{document}

After looking through previous questions on this site, I tried to modify one of the solutions given in this question to suit my needs. Here's my attempt (which is add-able to the minimal example file given above to run)

\newcount\rowc
\makeatletter

\def\ExampleCol{
\centering
\hbox\bgroup
\let\\\cr
\def\ruleb{
\ifnum\rowc=1\hrule height 1pt \else
\fi}
\valign\bgroup
\global\rowc\@ne
\hbox to 6em{\strut \hfill##\hfill}%
\ruleb
&&%
\global\advance\rowc\@ne
\hbox to 6em{\strut\hfill##\hfill}%
\ruleb
\cr}
\def\endExampleCol{%
\crcr\egroup\egroup}

Using this, the following code produces the accompanying picture:

\begin{ExampleCol}
\dakota{wáŋča, núŋpa, yámni, tópa, záptaŋ,sákpe}
\english{one, two, three, four, five, six}  
\end{ExampleCol}

enter image description here

Which is looking great (with the exception that I would like a horizontal bar at the bottom of the table as well but don't want to specify its height beforehand, and the top bar is a bit too close to the text)

However, this solution doesn't work for me as the cells seem to be of a fixed size, if I try and enter longer words in the table neighboring cells overlap. For example, the following code

\begin{ExampleCol}
\dakota{čhaŋté + oyúze,   čhaŋtóyuze,    čhaŋté + ohnáka,  čhaŋtóhnaka}
\english{heart + condition of,  disposition,    heart + to place inside,    to cherish} 
\end{ExampleCol}

produces this table:

enter image description here

Any suggestions on a good way to make an environment for entering tables in columns like this that doesn't have the same problems would be greatly appreciated!

2
  • I think, it would be better to store the English/Dakota word pairs together instead of using two lists. Splitting can be done later on.
    – user31729
    Jul 10, 2015 at 12:30
  • Is there any feedback on this?
    – user31729
    Mar 30, 2018 at 14:54

1 Answer 1

2

This is perhaps not the best way to achieve this, but the traversing of a list downwards within a table is tedious, since you have to store which row is currently processed, due to cell grouping.

This is perhaps a very ineffective solution -- it processes the list every time a row counter is incremented.

\documentclass{article}

\usepackage{etoolbox}

\listgadd{\Dakotalist}{}
\listgadd{\Englishlist}{}

\newcounter{rowcounter}
\newcounter{temprowcounter}

\newcommand{\processlist}[2]{%
  \typeout{#1}%
  \stepcounter{temprowcounter}%
  \ifnumless{\value{temprowcounter}}{#1}{%
  }{%
    \xdef\@@@@@localtemp{#2}%
    \listbreak%
  }%
}



\newcommand{\showrows}[2]{%
  #1 & #2 \tabularnewline
}

\newcommand{\processrows}[2]{%
  \stepcounter{rowcounter}%
  \setcounter{temprowcounter}{0}%
  \forlistloop{\processlist{\number\value{rowcounter}}}{#1}%
  \showrows{#2}{\@@@@@localtemp}%
}
\newcommand{\followrows}[2]{%
  \setcounter{rowcounter}{0}%
  \forlistloop{\processrows{#2}}{#1}%
}


\begin{document}

\forcsvlist{\listgadd\Dakotalist}{eins,zwei,drei,vier}
\forcsvlist{\listgadd\Englishlist}{one,two,three,four}


\begin{tabular}{lr}
\followrows{\Englishlist}{\Dakotalist}
\tabularnewline
\end{tabular}

And now reversed...

\begin{tabular}{lr}
\tabularnewline
\followrows{\Dakotalist}{\Englishlist}
\end{tabular}



\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .