Posts tagged ‘LaTeX’

Beamer Slides Template using Source Sans Fonts

Here’s a short example for a Beamer slide template using the Adobe Source Sans fonts.

\documentclass[12pt,ngerman]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{csquotes}
\usepackage{paralist}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{sourcesanspro}
\usepackage{sourcecodepro}
 
\definecolor{colBack}{rgb}{1,1,0.8}
\definecolor{colKeys}{rgb}{0,0,1}
\definecolor{colIdentifier}{rgb}{0,0,0}
\definecolor{colComments}{rgb}{1,0,0}
\definecolor{colString}{rgb}{0,0.5,0}
 
\lstset{%
    float=hbp,%
    basicstyle=\ttfamily\footnotesize, %
    identifierstyle=\color{colIdentifier}, %
    keywordstyle=\color{colKeys}, %
    stringstyle=\color{colString}, %
    commentstyle=\color{colComments}, %
    columns=flexible, %
    tabsize=2, %
    frame=single, %
    extendedchars=true, %
    showspaces=false, %
    showstringspaces=false, %
    numbers=left, %
    numberstyle=\tiny, %
    breaklines=true, %
    backgroundcolor=\color{colBack}, %
    breakautoindent=true, %
    captionpos=b%
}
 
\author{Uwe Ziegenhagen}
\title{Titel der Präsentation}
\institute{Köln}
 
\begin{document}
\frame{
	\maketitle
}
 
\frame[containsverbatim]{
\frametitle{Titel der Folie}
\framesubtitle{Untertitel der Folie}
 
\begin{itemize}
\item Erstes Item
\item Zweites Item
\item Drittes Item
\end{itemize}
 
\lstinputlisting[language={[LaTeX]TeX},basicstyle=\ttfamily\tiny,linerange={1-12},caption={Auszug aus der Präambel dieser Präsentation},label={lis:tex01}]{\jobname.tex}
}
 
\end{document}

source1

source2

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Animating TikZ Graphics

After drawing the cubic Bezier a few days ago I wanted to animate it. Using the animate package this is fairly simple:

\documentclass{article}
\usepackage[paperwidth=5.5cm,paperheight=5.3cm,left=0cm,right=0cm,bottom=0cm,top=0.25cm]{geometry}
\usepackage{tikz}
\definecolor{fom}{RGB}{0,153,139}
 
\newcommand{\dat}{0.7} % 0.67
\usepackage{animate}
 
\begin{document}
 
\begin{animateinline}[poster=last, controls, palindrome]{10}
\multiframe{70}{Ry=0.1+0.01}{
\begin{tikzpicture}[x=4cm,y=4cm]
\draw[line width=1pt,lightgray] (0,0) -- (1,1);
\draw (0,0) -- (1,0) -- (1,1) -- (0,1) -- (0,0); 
\draw (0,0) -- (0.17,0.67); 
\draw (1,1) -- (0.83,\Ry); 
 
\draw [magenta,fill=magenta](0.17,0.67) circle (.5ex); 
\draw [fom,fill=fom](0.83,\Ry) circle (.5ex); 
 
\draw[line width=1pt] (0,0) .. controls (0.17,0.67) and (0.83,\Ry) .. (1,1);
 
\node[label={[label distance=0.0cm,text depth=-1ex,rotate=90]left:Fortschritt in \%}] at (-0.1,.8) {};
\node[label={[label distance=0.0cm,text depth=-1ex]right:Zeit-Achse}] at (0,-0.05) {};
\end{tikzpicture}}
\end{animateinline}
 
\end{document}

I am animating in the TeX code (not externally) so I use animateinline with 10 frames per second. Inside this environment I prepare 70 frames, where I have the y-coordinate of the second point loop from 0.1 in steps of 0.01. The looping is controlled via Ry (that translates to \Ry in the loop). That’s it!

Here is the resulting PDF: bezier

PS: I used pdflatex from the TeX Live 2014.

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Drawing Bezier Curves with TikZ

To visualize an example for cubic-Bezier CSS animations (http://cubic-bezier.com) I decided to try TikZ. That was in fact a pretty good idea, as — with the help of Google (and mostly tex.stackexchange.com) I managed to complete the following example in just a few minutes:

\documentclass{article}
\usepackage[paperwidth=5.5cm,paperheight=5.3cm,left=0cm,right=0cm,bottom=0cm,top=0.25cm]{geometry}
\usepackage{tikz}
\definecolor{fom}{RGB}{0,153,139}
\begin{document}
 
\begin{tikzpicture}[x=4cm,y=4cm]
\draw[line width=1pt,lightgray] (0,0) -- (1,1); % gray line for the linear animation path
\draw (0,0) -- (1,0) -- (1,1) -- (0,1) -- (0,0); % frame
\draw (0,0) -- (0.17,0.67); % (0,0) to 2. point
\draw (1,1) -- (0.83,0.67); % (1,1) to 3. point
 
\draw [magenta,fill=magenta](0.17,0.67) circle (.5ex); %circle 1
\draw [fom,fill=fom](0.83,0.67) circle (.5ex); % circle 2
 
\draw[line width=1pt] (0,0) .. controls (0.17,0.67) and (0.83,0.67) .. (1,1); % cubic bezier curve
 
% labels
\node[label={[label distance=0.0cm,text depth=-1ex,rotate=90]left:Fortschritt in \%}] at (-0.1,.8) {};
\node[label={[label distance=0.0cm,text depth=-1ex]right:Zeit-Achse}] at (0,-0.1) {};
\end{tikzpicture}
\end{document}

The result is pretty impressive.

bez

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

LaTeX \\ in externe Dateien schreiben

Ich hatte kürzlich die Notwendigkeit, Adressen wie die folgende aus KOMA Briefen in eine externe Datei zu schreiben:

\newcommand{\Anschrift}{John Doe \\ Berlin}

http://stackoverflow.com/questions/2115379/write-and-read-from-a-latex-temporary-file funktionierte leider nicht, da LaTeX das Schreiben der „\\“ bemängelte.

Auch der Weg über \unexpanded führte nicht weiter, da LaTeX dann nur den Befehl, nicht die Expansion in die Datei schreibt.

Die Lösung steckte dann in einer anderen Frage auf TSX: http://tex.stackexchange.com/questions/110883/writing-to-a-file

Das folgende Beispiel ist dabei rausgekommen:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xpatch}
 
\makeatletter
% get a copy of `\protected@write
\let\protected@iwrite\protected@write
% patch the copy to add \immediate
\xpatchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}
\makeatother
 
\newwrite\tempfile
\newcommand{\Anschrift}{John Doe \\ Berlin}
\immediate\openout\tempfile=Anschrift.txt
\makeatletter
\protected@iwrite\tempfile{\let\\\relax}{\Anschrift}
\immediate\closeout\tempfile
\makeatother
 
\begin{document}
 
\input{Anschrift.txt}
 
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Typesetting Chessboard with the chessboard package

I recently started Chess again, so I wanted to typeset some chessboards. With the chessboard package by Ulrike Fischer this is pretty much straight forward. Here’s a 2-page example what the package can do. It can do much more, I’ll post additional examples if I find some time.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[left=1cm,right=1cm,top=2cm,bottom=2cm]{geometry}
\usepackage{chessboard,xskak}
\usepackage{graphicx,booktabs}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}\centering
 
\scalebox{2}{\chessboard[setpieces={Ne4,Ka1,ka2}]}
 
\scalebox{2}{%
\setchessboard{showmover=false}
\newchessgame
\chessboard}
 
\scalebox{2}{%
\setchessboard{showmover=true}
\chessboard[setpieces={Ka1,ka2,Rb1,rb2,Nc1,nc2,Qd1,qd2,Be1,be2,Pf1,pf2,Qd3},
    pgfstyle=straightmove,
    arrow=stealth,
    linewidth=.25ex,
    padding=1ex,
    color=red!75!white,
    pgfstyle=straightmove,
    shortenstart=1ex,
    showmover=true,
    markmoves={d3-h7,d3-a6,d3-b1,d3-f1,d3-d8,d3-d1,d3-a3,d3-h3}]
}
 
Capital letters for white, small letters for black.
 
\begin{tabular}{cll} \toprule
Letter & English & German \\ \midrule
K & King & König \\
Q & Queen & Dame \\
R & Rook & Turm \\
N & Knight & Pferd \\
B & Bishop & Läufer \\
P & Pawn & Bauer \\ \bottomrule
\end{tabular}
 
\end{document}

chess

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Cross-referencing labels in other files

With the xr package one can pull labels from different files, however it is not possible to create hyperref-Hyperlinks with this package.

Fortunately there is a was around this challenge:

„Label-Dokument.tex“ with the label inside

%!TEX TS-program = Arara
% arara: pdflatex
\documentclass[12pt]{scrartcl}
 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\hypersetup{
    bookmarks=true,                     % show bookmarks bar
    unicode=false,                      % non - Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,                        % show Acrobat’s toolbar
    pdfmenubar=true,                        % show Acrobat’s menu
    pdffitwindow=false,                 % window fit to page when opened
    pdfstartview={FitH},                    % fits the width of the page to the window
    pdftitle={Title},                        % title
    pdfauthor={Author},                 % author
    pdfsubject={Subject},                   % subject of the document
    pdfcreator={LaTeX},                   % creator of the document
    pdfproducer={LaTeX},             % producer of the document
    pdfkeywords={keyword1} {key2} {key3},   % list of keywords
    pdfnewwindow=true,                  % links in new window
    colorlinks=true,                        % false: boxed links; true: colored links
    linkcolor=blue,                          % color of internal links
    citecolor=blue,                          % color of internal links
    filecolor=blue,                     % color of file links
    urlcolor=blue                        % color of external links
}
\begin{document}
 
\section{Some Section}
 
In this file I am setting a label. \label{lab:label1}
 
\end{document}

„Ref-Dokument“ with the reference to „Label-Dokument“

%!TEX TS-program = Arara
% arara: pdflatex
\documentclass[12pt,ngerman]{scrartcl}
 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{hyperref}
\hypersetup{
    bookmarks=true,                     % show bookmarks bar
    unicode=false,                      % non - Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,                        % show Acrobat’s toolbar
    pdfmenubar=true,                        % show Acrobat’s menu
    pdffitwindow=false,                 % window fit to page when opened
    pdfstartview={FitH},                    % fits the width of the page to the window
    pdftitle={Title},                        % title
    pdfauthor={Author},                 % author
    pdfsubject={Subject},                   % subject of the document
    pdfcreator={LaTeX},                   % creator of the document
    pdfproducer={LaTeX},             % producer of the document
    pdfkeywords={keyword1} {key2} {key3},   % list of keywords
    pdfnewwindow=true,                  % links in new window
    colorlinks=true,                        % false: boxed links; true: colored links
    linkcolor=blue,                          % color of internal links
    citecolor=blue,                          % color of internal links
    filecolor=blue,                     % color of file links
    urlcolor=blue                        % color of external links
}
\usepackage{zref-xr,zref-user}
\usepackage{nameref}
\zxrsetup{toltxlabel}
\zexternaldocument*{Label-Dokument}
\begin{document}
 
In this document I reference the external label in section \ref{lab:label1} on page \pageref{lab:label1} of the external document.
 
\end{document}

ref

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Installing & using the nonfreefonts in TeX Live 2013

Update 2017-12-10: Markus Kohm told me there were some changes:

  • getnonfreefonts --all does not work anymore
  • the best way is getnonfreefonts --sys

Original article:

Since there was a question on TSX how to use Arial in a LaTeX document I had a closer look on the nonfreefonts stuff and want to share this knowledge.

What’s it all about?

There are various fonts available on CTAN which — due to copyright/licensing stuff — can’t make it to the TeX Live DVD. These fonts are:

  • Arial by URW
  • Classico by URW
  • DayRoman by Apostrophiclabs
  • Euro symbols by Adobe
  • GaramondNo8 by URW
  • GaramondNo8 Expert by Michael Sharpe
  • LetterGothic by URW
  • LuxiMono by Bigelow & Holmes
  • VnTeX nonfree by Hàn Thế Thành
  • Webomints by Galapagos Design Group

How to install them

Since they’re not on the DVD these fonts need to be installed separately. Font installation for TeX is always tidious (copy these files there, some other files there, update this file) so Reinhard Kotucha created a script which does these nasty things for us. The good thing is, this script works on all TeX Live platforms.

Step 1: Getting the script

If you’re on any Linux/Unix platform run:


wget http://tug.org/fonts/getnonfreefonts/install-getnonfreefonts
texlua install-getnonfreefonts

If you’re on Windows, either install wget (always a good idea) or visit http://www.tug.org/fonts/getnonfreefonts/ with your browser and download the installer linked there. Afterwards just run texlua on the file, it will take care of the script-installation.


J:\>texlua install-getnonfreefonts
Detected System: win32
Detected Installation: C:/texlive/2013
mkdir C:/texlive/2013/texmf-dist/scripts/getnonfreefonts ...             [done]
Installing texmf-dist/scripts/getnonfreefonts/getnonfreefonts.pl ...     [done]
Installing texmf-dist/doc/man/man1/getnonfreefonts.1 ...                 [done]
Installing texmf-dist/doc/man/man1/getnonfreefonts-sys.1 ...             [done]
Installing texmf-dist/doc/man/man1/getnonfreefonts.man1.pdf ...          [done]
Installing texmf-dist/doc/man/man1/getnonfreefonts-sys.man1.pdf ...      [done]
md5sum: eb97b3fe32b28ead5183275ad32699b8 getnonfreefonts.pl ...            [ok]
md5sum: f850d910dd96ee27cecdb3772047d247 getnonfreefonts.1 ...             [ok]
md5sum: fb2b0f7699db8e627d4e26b730e94928 getnonfreefonts-sys.1 ...         [ok]
md5sum: 415b51f7c80a4abe8d0a667a04c9d525 getnonfreefonts.man1.pdf ...      [ok]
Creating wrappers in 'bin/win32' ...                                           1
 Datei(en) kopiert.
        1 Datei(en) kopiert.
  [done]
texhash: Updating C:/texlive/2013/texmf-dist/ls-R...
texhash: Updated C:/texlive/2013/texmf-dist/ls-R.
texhash: Done.

J:\>

Step 2: Installing the fonts

Just run getnonfreefonts --all to install all the fonts in your user texmf directory ($TEXMFHOME) or
getnonfreefonts-sys --all to install to the system directory ($TEXMFLOCAL).

J:\>getnonfreefonts --all
--2014-03-30 09:51:38--  http://tug.org/~kotucha/getnonfreefonts/getfont2013
Resolving tug.org... 130.225.2.178
Connecting to tug.org|130.225.2.178|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23858 (23K)
Saving to: `getfont2013'

100%[======================================>] 23,858      --.-K/s   in 0.1s

2014-03-30 09:51:38 (223 KB/s) - `getfont2013' saved [23858/23858]

------------------------------------------
Installation directory: C:/Users/Uwe/texmf
------------------------------------------

Package 'arial-urw':
====================

--2014-03-30 09:51:39--  http://ctan.org/tex-archive/fonts/urw/arial.zip
Resolving ctan.org... 176.28.54.184
Connecting to ctan.org|176.28.54.184|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://mirrors.ctan.org/fonts/urw/arial.zip [following]
--2014-03-30 09:51:39--  http://mirrors.ctan.org/fonts/urw/arial.zip
Resolving mirrors.ctan.org... 176.28.54.184
Reusing existing connection to ctan.org:80.
HTTP request sent, awaiting response... 302 Found
Location: ftp://ftp.tu-chemnitz.de/pub/tex/fonts/urw/arial.zip [following]
--2014-03-30 09:51:39--  ftp://ftp.tu-chemnitz.de/pub/tex/fonts/urw/arial.zip
           => `arial.zip'
Resolving ftp.tu-chemnitz.de... 134.109.228.1
Connecting to ftp.tu-chemnitz.de|134.109.228.1|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/tex/fonts/urw ... done.
==> SIZE arial.zip ... 249649
==> PASV ... done.    ==> RETR arial.zip ... done.
Length: 249649 (244K)

100%[======================================>] 249,649      656K/s   in 0.4s

2014-03-30 09:51:40 (656 KB/s) - `arial.zip' saved [249649]

4ad05e902e727fecc4f55f8d737e10a5  arial.zip                 [MD5sum ok]

Extracting 'arial.zip'...                                   [done]
Installing 'ua1.map'...                                     Creating new config
file c:/users/uwe/.texlive2013/texmf-config/web2c/updmap.cfg
[done]

Step 3: Using the fonts

Under http://www.tug.dk/FontCatalogue/lettergothic/
you will find an example how to use for example the lettergothic font.

\documentclass[12pt,ngerman]{scrartcl}
 
\usepackage[scaled]{ulgothic}
\renewcommand*\familydefault{\ttdefault} %% Only if the base font of the document is to be typewriter style
\usepackage[T1]{fontenc}
 
\begin{document}
 
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam dictum felis a nibh, eu condimentum lectus auctor. Cras quis euismod lorem. Aliquam in nisi felis. Etiam sit amet mauris at magna rhoncus commodo. Nulla neque ipsum, condimentum in nibh sed, eleifend consectetur est. Suspendisse ac laoreet urna. Vivamus sit amet tempor nunc, ac porta mi. Pha\-sellus et ligula ullamcorper, congue ligula non, porta purus. Etiam cursus eros ante, sit amet porta enim adipiscing sed. Vestibulum hendrerit erat a tellus dignissim, sit amet lao\-reet est suscipit. 
 
\end{document}

gothic

Step 4: Overview of all examples

Arial

\usepackage[scaled]{uarial}
\renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be sans serif
\usepackage[T1]{fontenc}

Classico

\renewcommand*\sfdefault{uop}
\renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be sans serif
\usepackage[T1]{fontenc}

DayRoman

\renewcommand*\rmdefault{dayrom}
\usepackage[T1]{fontenc}

Garamond

\usepackage[urw-garamond]{mathdesign}
\usepackage[T1]{fontenc}

Garamond Expert

\usepackage[T1]{fontenc}
\usepackage[urw-garamond]{mathdesign}
\usepackage{garamondx}

Letter Gothic

\usepackage[scaled]{ulgothic}
\renewcommand*\familydefault{\ttdefault}
\usepackage[T1]{fontenc}

Luxi Mono

\usepackage{luximono}
\renewcommand*\familydefault{\ttdefault}
\usepackage[T1]{fontenc}

webomints

See http://www.ctan.org/tex-archive/fonts/webomints

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

C5 Umschläge mit LaTeX bedrucken

Hier ein kleines Beispiel, wie man mit LaTeX DIN C5/6 Umschläge vorbereiten kann. Die exakten Positionen sind so gewählt, dass mein Epson LQ-870 sie (mit gut Zureden) verarbeiten kann.

\documentclass[12pt]{scrartcl}
\usepackage[paperwidth=22cm,paperheight=11cm,left=0cm,top=0cm,right=0cm,bottom=0cm]{geometry}
 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ocr}
\usepackage{xcolor}
\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
\setlength{\parindent}{0cm}
\setlength{\parskip}{0cm}
 
\begin{document}\ocrfamily 
 
\begin{textblock}{5}[0,0](1,0.25)\footnotesize
Sender Line 1\\
Sender Line 2 \\
Sender Line 3
\end{textblock}
 
\begin{textblock}{6}[0,0](12,5)%
Receiver Line 1 \\
Receiver Line 2 \\
Receiver Line 3 
\end{textblock}
 
\end{document}

umsch

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Configuring Arara under TeXworks

Here’s a short tutorial how to configure Arara under TeXworks:

1) Open the TeXworks settings (In the German version via „Bearbeiten“ => „Einstellungen“ => „Textsatz“)

2) Click the ‚+‘ button

step01

3) Specify a new name and command

step02

4) Specify the options to be given to Arara when called from TeXworks

step03

5) Final optional step: Move the new tool up in the toolchain.

step04

The following code snippet should work fine then. The first line is evaluated by TeXworks, it automatically switches the TeX engine.

%!TEX TS-program = Arara
% arara: pdflatex
\documentclass[12pt,ngerman]{scrartcl}
 
\begin{document}
 
Hello Arara!
 
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Generating math exercises for kids with LuaLaTeX

Arno T. has sent me a nice piece of LuaLaTeX code that does more or less the same thing as my Python code. I guess, I should have a closer look at LuaLaTeX.

\documentclass{scrartcl}
\usepackage{booktabs}
\usepackage{luacode}
\usepackage{longtable}
 
\begin{document}
\begin{longtable}{rcrcl}
\toprule
\luaexec{
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
random = math.random
tp = tex.print
%
min = 1
max = 10
math.randomseed(os.time())
for i = 1,20 do
a = random(min,max)
b = random(min,max)
op = random(1,4)
if (op==1) then
c = a+b
tp(a.."&+&"..b.."&=&"..c.."\\\\")
elseif (op==2) then
c = a-b
tp(a.."&-&"..b.."&=&"..c.."\\\\")
elseif (op==3) then
c = a*b
tp(a.."&*&"..b.."&=&"..c.."\\\\")
elseif (op==4) then
c = a/b
tp(a.."&/&"..b.."&=&"..round(c,3).."\\\\")
end
end
tex.print("\\bottomrule")
}
\end{longtable}
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website