1

I'm currently learning japanese, and since they have different characters, I'm doing some practice where I make a table, in which each cell contains the pronounciation of one of their characters, and an empty box below that I can type the character in after printing the sheet.

a box

The problem is that I would like to have the order of the characters be different each time, so I'm looking for a way, such that I can create a LaTeX document which when compiled gives a page filled like the above image, with each A being some item in a given list.

It's fine if the randomness is supplied from somewhere else if LaTeX cannot create randomness itself, such as a seperate document that I simply put the time in, or a commandline parameter.

If it makes the process any easier I have created the following template which I would like the documents to follow. My question would be answered if the \nextchar macro is replaced with something that picked a random character from some set of given characters.

\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{easytable}

\newcommand{\nextchar}{{\Huge A}}

\begin{document}
\pagenumbering{gobble}
\begin{center}
  \begin{TAB}(e,12ex,5ex){|c|c|c|c|c|c|c|c|c|c|}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
  \end{TAB}
\end{center}
\end{document}
  • Could you please provide MWE, or do you have a PDF file with information about one character per page, or you have some data? – Malipivo Mar 25 '15 at 19:59
  • @Malipivo Please elaborate on ''MWE'', what do you mean with ''PDF file with information about one character per page'', and what kind of information do you want? – Alice Ryhl Mar 25 '15 at 20:02
  • MWE (meta.tex.stackexchange.com/questions/228/…) is a code we can start working on it. Sometimes it is useful to have cards (e.g. one kanji per page) and then a task is to select some of them from huge pdf using pgfpages/tikz or similar tools. We would like to help you, but your question is too general. – Malipivo Mar 25 '15 at 20:11
  • @Malipivo That's a reasonable request, how would the best method be for me to provide the document the characters to put in the boxes? A pdf with one on each page as you mentioned? Some kind of array containing the LaTeX code for whatever to put in the box? – Alice Ryhl Mar 25 '15 at 20:15
  • TikZ can handle randomness nicely, see rnd and rand functions in the reference manual. A tip for you, how we can select some pages out of a big PDF file in LuaTeX (selecting pages without repetitions), tex.stackexchange.com/questions/145160/…. – Malipivo Mar 25 '15 at 20:22
2

Here's a LuaLaTeX-based solution. You have to store your characters into charlist (the variable) as shown below. Then it will count the list and uses randomly chosen characters using your \nextchar macro.

random table

\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{easytable}

\directlua{
    charlist = {"A","B","C","D","E","F","G"}
    maxv = 0
    for _ in pairs(charlist) do maxv = maxv + 1 end
}
\newcommand{\nextchar}{{\Huge%
    \directlua{
        tex.print(charlist[math.random(1,maxv)])
    }
}}

\begin{document}
\pagenumbering{gobble}
\begin{center}
  \begin{TAB}(e,12ex,5ex){|c|c|c|c|c|c|c|c|c|c|}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
    \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar & \nextchar \\
              &&&&&&&&&\\
  \end{TAB}
\end{center}
\end{document}

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.