3

Warning: I am only just getting started with this LaTeX and have no experience in writing this 'code-like' language.

I started on making cards for a boardgame for my pupils. After finally getting 1 card, both question and answer fixed, and the layout being quite ok I am stuck. I have no idea how or where (what command what line etc) to start or create a new card and responding answer.

Kind regards,

Code Sample

\documentclass[a7paper,print,10pt,grid=rear]{kartei}
%Voor info googelen op 'LaTeX kartei'
%a7paper: bepaalt hoe groot de fiches worden.  a6-a7-a8-a9 zijn de opties
%grid: geeft aan of er snijlijnen moeten geprint worden.  
\usepackage[latin1]{inputenc}
\usepackage[dutch]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{icomma}

%\usepackage[version=3]{mhchem}%enkel nodig om chemische formules te kunnen gebruiken


%Om te zorgen dat het antwoord in het midden van de kaart komt te staan.  
\newcommand{\antwoord}[1]{
\vspace*{\fill}
\begin{center}
#1
\end{center}
\vspace*{\fill}
}

\newcommand{\vraag}[1]{#1}

\newcommand{\kaart}[2]{
\begin{karte}[Vraag]{\vraag{#1} }
\answer{Antwoord}

\antwoord{#2}

\end{karte}
}

\author{T. Dierckx}

\begin{document}

\kaart{Bereken:

$2^{5}\cdot 2^{2}=$}{$2^{7}=128$}

\end{document}}
8
  • Hi, if this helps you in anyway... math.utah.edu/~jasonu/flash-cards – crypto May 24 '16 at 12:22
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. It will be easier for others to help if you include the actual code of your document instead of a screenshot (you can edit your question and use the "code sample {}" button to format selected lines as code). That having been said, it looks like your \kaart command takes two arguments, and you may have only given it one argument on line 39. – Mike Renfro May 24 '16 at 12:26
  • @MikeRenfro Like this? (the code sample) I did (i think) include the second part of the \kaart command but it wasn't shown in the printscreen. My apologies. – Michelle_B May 24 '16 at 12:36
  • for each card, you need to create following command: \kaart{<question>}{<answer>} and replace <question> and <answer> accordingly. – ebosi May 24 '16 at 12:41
  • And i can write it just right after what line? – Michelle_B May 24 '16 at 12:43
4

To create a new card, just insert following command in your document (i.e. between \begin{document} and \end{document}) and replace <question> and <answer> accordingly: \kaart{<question>}{<answer>}
You need to call this command for each card you want to create.

Here is an example with a second card (see below for detailed explanations):

\documentclass[a7paper,print,10pt,grid=rear]{kartei}
    %Voor info googelen op 'LaTeX kartei'
    %a7paper: bepaalt hoe groot de fiches worden.  a6-a7-a8-a9 zijn de opties
    %grid: geeft aan of er snijlijnen moeten geprint worden.  
    \usepackage[latin1]{inputenc}
    \usepackage[dutch]{babel}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{icomma}

    %Om te zorgen dat het antwoord in het midden van de kaart komt te staan.  
    \newcommand{\antwoord}[1]{
        \vspace*{\fill}
        \begin{center}
            #1
        \end{center}
        \vspace*{\fill}
    }

    \newcommand{\vraag}[1]{
        #1
    }

    \newcommand{\kaart}[2]{
        \begin{karte}[Vraag]
            \vraag{#1}
            \answer{Antwoord}
            \antwoord{#2}
        \end{karte}
    }

    \author{T. Dierckx}

\begin{document}
    \kaart{Bereken: $2^{5}\cdot 2^{2}=$}{$2^{7}=128$}
    \kaart{Bereken: $e^{i\pi}+1=\text{?}$}{$0$}
\end{document}

How does your code work?

  • First, you define what kind of document/layout you want creating, with some options. LaTeX will thus know which already-implemented rules have to be followed.

    \documentclass[a7paper,print,10pt,grid=rear]{kartei}
    
  • Then, you load some so-called packages: they are literally packages that gives you the ability to use new rules (i.e. macro-commands) and that can set up some LaTeX-settings for you.

    \usepackage[<eventually some options>]{<package-name>}
    
  • Then, you define your own commands

    \newcommand{\<name-of-the-new-command}[<number-of-arguments]{<definition of what the command does>}
    
  • And eventually, given all these settings and informations, you begin to describe what is the content of your document.

    \begin{document}
        <content-of-your-document>
    \end{document}
    

How does the \kaart command work?

You have define in your preamble (all the code from \documentclass to \begin{document}) a command called \kaart. Let see how it works.

  • \newcommand{\kaart}: you create a new command named \kaart! It will return an error if a command already has this name.
  • [2]: this command has two arguments. Thus, when you want to use this command, you have to write \kaart{<first-argument>}{<second-argument>}.
  • { <command-definition> }: what the command does is defined within these curly-brackets.
    • \begin{karte}[Vraag]: it begins a (previously define in kartei.cls file) environment named kaarte with the argument Vraag. This environment will be closed with \end{karte}. -\vraag{#1}: You then call the command \vraag with one argument { <argument>}. #1 means that this argument is actually the <first-argument> you gave as argument of \kaart.
    • \answer{Antwoord}: You call the command \answer with the argument Antwoorkd.
    • \antwoord{#2}: You should have guessed it: you call the command (or function, or macro) \antwoord with one argument, which is <second-argument>, the second argument you gave when you called the \kaart command.

So writing \kaart{<first-argument>}{<second-argument>} is the same than writing

\begin{karte}[Vraag]
    \vraag{<first-argument>}
    \answer{Antwoord}
    \antwoord{<second-argument>}
\end{karte}

But it's shorter... and you can easily re-use it!

Thus, within your document (i.e. between \begin{document} and \end{document}) you can call several times the command \kaart{<question>}{<answer>} as in the example.

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.