3

I am working on putting together a grammar book which has a lot of bilingual examples, and simultaneously trying to learn the memoir class. The book will have many tables which look like the following in it: enter image description here

For reference, here is the code I used to make the table above (Where \dak and \eng are just shorthand names for two different fonts I'm using with XeLateX.)

\begin{center}
\begin{tabular}{ c c c}
\toprule
{\dak wayáte} & {\dak waŋčhíyaŋke} & {\dak wičháuŋk'upi}\\
{\eng You ate.} & {\eng I see you.} & {\eng We gave it to them. }\\
&&\\
{\dak čhičhíčaǧe} & {\dak nihdúžaža }& {\dak šá}\\
{\eng I made it for you.} & {\eng You washed yourself.} & {\eng It is red.}\\ 
\bottomrule
\end{tabular}
\end{center}

However, I'd much prefer to design some sort of environment / command that will automatically take in a list of words and their translations like this, and output a correctly formatted table. Here was one of my initial attempts at such a project:

\documentclass{memoir}
\usepackage{fontspec}
\newfontfamily\dak{Linux Biolinum O}
\newfontfamily\eng{JosefinSans-SemiBold}
\newenvironment{DakEx31}[6]{% 
\begin{table}
\centering
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{*{3}{c}}
    \toprule
{\dak #1} &{\dak #2}&{\dak #3}\\
{\eng #4}&{\eng #5}&{\eng #6}\\
\bottomrule
}
{\end{tabular}
\end{table}}


\begin{document}

\begin{DakEx31}
{wayáte}{waŋčhíyaŋke}{wičháuŋk'upi}
{You ate.}{I see you.}{We gave it to them.}
\end{DakEx31}

\end{document}

To produce a nice looking table 3 examples wide and 1 tall. However, obviously going with this approach I would need to define a different command for each size table I would want, which I would like to avoid should it become necessary to add to / change the examples provided in a given section as the writing process progresses. Also, this approach fails as I try and make my tables much larger as such a command can only accept 9 inputs.

My main experience with TeX is typing mathematical papers; and so I do not know enough to be able to design the kind of environment I need here. What I'm looking for is a command where I can specify the number of columns (and the number of rows, if necessary), and then input a list of words / their translations, and then have the output be a nicely formatted table with the text in Dakota in one font, the text in English in another, and a blank row between rows of examples. Thanks!

3
  • 1
    You could try this. You would just have to indicat the number of columns every time. Also you should give a complete minimal example as I don't think the \dak command is default. – anderstood Jun 11 '15 at 23:32
  • Thanks! I have filled in the rest of the code in the example so that it is functional (possibly after changing the fonts), and I'll take a look at your suggestion! However I'm concerned I don't know enough to modify it so that the font will be different depending on which cell is being edited in the loop. – Steve Jun 12 '15 at 0:03
  • If you ever have a few days off, lualatex is worth learning and would accommodate this kind of stuff easily. – JPi Jun 12 '15 at 1:04
4

This should do the trick. As I don't have your fonts installed, I used \textsf and \textit instead, but you should be able to adapt it to your will.

There is not much to say, I adapted the solution give here.

Note that the maximum number of columns is defined in the variable \maxcolumns. You can change it as you wish.

enter image description here

Usage is the following:

\begin{vartab}
  \english{word1,word2,word3,word4}
  \french{mot1,mot2,mot3,mot4}
\end{vartab}

Complete code:

\documentclass{memoir}
%\usepackage{fontspec}
%\newfontfamily\dak{Linux Biolinum O}
%\newfontfamily\eng{JosefinSans-SemiBold}
\newcommand\dak{\textsf}
\newcommand\eng{\textit}


\renewcommand{\arraystretch}{1.2}

\usepackage{etoolbox}

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


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

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


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

\def\maxcolumns{20}

\begin{document}
\thispagestyle{empty}

\begin{vartab}
\english{Word1,Word2,Word3}
\french{Mot1,Mot2,Mot3}
\end{vartab}

\begin{vartab}
\english{word1,word2,word3,word4}
\french{mot1,mot2,mot3,mot4}
\end{vartab}

\begin{vartab}
\english{word1,word2,word3,word4,word5,word6,word7,world8,word9,word10}
\french{mot1,mot2,mot3,mot4,mot5,mot6,mot7,mot8,mot9,mot10}
\end{vartab}

\end{document}
2
  • @Steve Just realised it is not exactly what you ask but if it's OK... :) – anderstood Jun 12 '15 at 22:17
  • Yeah it works fine for what I need; basically anything that will let me make tables like this quickly will work just fine, thanks again! – Steve Jun 12 '15 at 22:18
2

Not a complete answer as it doesn't deal with the rules before and after, but here goes. It uses the memoir \autorows macro.

\documentclass{memoir}
\newcommand{\trans}[2]{\shortstack{#1 \\ \textbf{#2} \\ \mbox{}}}
\pagestyle{empty}
\begin{document}
\autorows{c}{3}{c}{%
  trans{one}{eins},\trans{two}{zwei},\trans{three}{drei},\trans{four}{vier}.
  \trans{five}{funf},\trans{six{sechs},    \trans{seven}{sieben}}
\end{document}

enter image description here

1
  • I have difficulty in inserting a pdf image as produced by pdflatex. The site doesn't seem to like pdf files so I used `convert in.pd out.jpg' but the result was not good. Any advice is welcome. – Peter Wilson Jun 13 '15 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.