Author Archive

A simple exsheets/tasks Example

Here’s a simple example for the exsheets/tasks packages, taken from the tasks Documentation.

\documentclass[12pt,ngerman]{scrartcl}
 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{tasks}
\usepackage{exsheets}
 
\begin{document}
 
\settasks{
counter-format = qu.tsk,
item-indent = 2em,
label-width = 2em,
label-offset = 0pt
}
 
\begin{question}[type=exam]{4}
I have these two tasks for you. Shall we begin?
\begin{tasks}(2)
\task The first task: easy!
\task The second task: even more so!
\end{tasks}
\end{question}
 
\begin{solution}[print]
Now, let's see\ldots\ ah, yes:
\begin{tasks}
\task This is the first solution. Told you it was easy.
\task This is the second solution. And of course you knew that!
\end{tasks}
\end{solution}
 
\end{document}

ex

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

MS Excel: Komplexe Wenn()-Formeln durch Vergleich ersetzen

Vor kurzem hatte ich eine kleine Herausforderung in Excel: Beträge in Spalte C mussten mit negativem Vorzeichen versehen werden, in Abhängigkeit einer Zahl in Spalte B (gelb markiert im Bild). Lösen lässt sich dies per verschachtelter WENN() Funktion, bei vielen Verschachtelungen wird die Formel aber schnell unübersichtlich und fehleranfällig. Deutlich einfacher und übersichtlicher geht es über eine Mischung aus VERGLEICH() und ISTNV(), die ich bei stackexchange gefunden hatte.

=WENN(ISTNV(VERGLEICH([@Unterkonto];unterkonten;0));[@Amount];-1*[@Amount])

  • für die Zahlen, die den Vorzeichenwechsel auslösen, habe ich einen benannten Bereich ‚unterkonten‘ festgelegt
  • VERGLEICH() schaut, ob ein Wert (der erste Parameter) in einer Liste (zweiter Parameter) vorhanden ist. Wird ein Wert nicht gefunden, wird #NV zurückgeliefert. Der zweite Parameter kann auch ein benannter Bereich sein.
  • Um die #NV Werte zu behandeln, prüfen wir mit ISTNV() die Rückgabe der VERGLEICH() Funktion
  • Die Rückgabe von ISTNV() wird dann per WENN() geprüft. Wenn ISTNV() WAHR zurückliefert, dann hat VERGLEICH() das Konto nicht in der Liste gefunden, sonst ist der Werte aus Spalte „Amount“ mit -1 zu multiplizieren.

Download der Excel-Datei

Excel Vergleich ISTNV

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

Committing to Subversion Repo directly from TeXworks

The following is a rather dirty trick to commit to Subversion directly from TeXworks. A clean implementation would make use of the scripting APIs in TeXworks, I am also working on that. Until then here’s the trick.

Just create a new tool entry, which calls svn (assuming that the path to svn is included in the PATH variable) and add the tree options: ci, -m and „“

svn_artikel_20140611

Does anyone know how to write a corresponding script? I gave it a try but haven’t come far…

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

Creating menus with Autohotkey

Here’s a simple example how to create a menu with Autohotkey, in this case it allows the user to select one of the LaTeX standard environments itemize, enumerate or description when Alt-y is pressed.

!y::
Gui, 1:Destroy
Gui, Add, Text,, Please enter the environment:
Gui, Add, DDL, vList, itemize||enumerate|description
Gui, Add, Button, Default, Input
Gui, Show
return

ButtonInput:
Gui, Submit, NoHide
Gui, 1:Destroy
Send %List%
return

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

Testing TeX Live’s Aurial font

A few days ago I checked the LaTeX Font Catalogue and found a nice font, Aurial.

\documentclass[12pt,ngerman]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{aurical}
 
\begin{document}
 
\section{Fontlukas}\Fontlukas
 
 
\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. 
 
\section{Fontamici}\Fontamici
 
\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. 
\section{Fontlukas-bfseries} \Fontlukas\bfseries
 
\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. 
 
\section{Fontlukas-slshape} \Fontlukas\slshape
 
\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. 
 
\section{Fontlukas-bfseries-slshape} \Fontlukas\bfseries\slshape
 
\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. 
 
\end{document}

fonti

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

How to define several listing environments

The following example shows how to define several listing environments with different highlightings and style settings.

\documentclass{scrartcl}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{bera}
 
\definecolor{hellgelb}{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{%
    basicstyle=\ttfamily\small%
}
 
% http://tex.stackexchange.com/questions/159419/different-colors-for-default-and-language-specific-listings
 
\lstdefinestyle{mytexstyle}{
    float=hbp,%
    identifierstyle=\color{colIdentifier}, %
    keywordstyle=\color{colKeys}, %
    stringstyle=\color{colString}, %
    commentstyle=\color{colComments}, %
    columns=flexible, %
    tabsize=2, %
 %   frame=single, %
    extendedchars=true, %
    showspaces=false, %
    showstringspaces=false, %
    backgroundcolor=\color{hellgelb}, %
    breakautoindent=true, %
    captionpos=b%
}
 
\lstdefinestyle{mypythonstyle}{
    float=hbp,%
    identifierstyle=\color{colIdentifier}, %
    keywordstyle=\color{colKeys}, %
    stringstyle=\color{colString}, %
    commentstyle=\color{colComments}, %
    columns=flexible, %
    tabsize=2, %
  %  frame=single, %
    extendedchars=true, %
    showspaces=false, %
    showstringspaces=false, %
    backgroundcolor=\color[gray]{0.95},
    breakautoindent=true, %
    captionpos=b%
 }
 
 
 
% http://stackoverflow.com/questions/741985/latex-source-code-listing-like-in-professional-books?rq=1
\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
 
 
 
% http://www.golatex.de/caption-fuer-lstnewenvironment-t9200.html
 
\lstnewenvironment{mytex}[2]
  {\lstset{language={[LaTeX]TeX},style=mytexstyle,caption={#1},label={#2}}}
  {}
 
 \lstnewenvironment{mypython}[2]
  {\lstset{language={Python},style=mypythonstyle,caption={#1},label={#2}}}
  {} 
 
\begin{document}
 
Here's some \LaTeX\ source code.
 
\begin{mytex}{Some \LaTeX\ code}{latex}
%!TEX TS-program = Arara
% arara: pdflatex
\documentclass[12pt,ngerman]{scrartcl}
 
\begin{document}
Hello \LaTeX!
 
\end{document}
\end{mytex}
 
Here's some Python source code.
 
\begin{mypython}{Some Python source to calculate the Fibonacchi number for a given number. This caption exceeds one line.}{py1}
def calcFibo(n):
	if n==0:
		return 0
	if n==1:
		return 1
	else:
		return calcFibo(n-1)+calcFibo(n-2)
 
print(calcFibo(25))
\end{mypython}
 
 
See listing \ref{latex} on page \pageref{latex}
 
\end{document}

listi

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

Accessing FTP servers with Python

Here’s a short code sample how to list a remote directory via FTP.

from ftplib import FTP
 
ftp = FTP('server')
ftp.connect()
ftp.login('user','password')                    
ftp.cwd('folder')              
ftp.dir()
ftp.quit()

Hier noch der passende Code für den Upload von Dateien:

import ftplib
import os
 
def upload(ftp, file):
    ext = os.path.splitext(file)[1]
    print("Putting ", file)
    if ext in (".txt", ".htm", ".html" , ".tex"):
        ftp.storlines('STOR ' + file, open(file,'rb'))
    else:
        ftp.storbinary('STOR ' + file, open(file,'rb'))
 
ftp = ftplib.FTP("remoteserver")
ftp.login("user", "password")
 
upload(ftp, "index.html")

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