Before I describe the implementation, I would like to describe this environment:
- When I run the command diary, an instance of kate opens a file named with the current date (e.g. 2010-12-09.tex, located in a directory, let's say $DIARY)
- If this file exists, then a warning appears, and it is opened
- Otherwise, this file is created
- This file contains a skeleton for a LaTeX document, where I immediately can start writing down my thoughts
- In the terminal-area of kate, I simply have to type pdflatex 2010-12-09.tex to compile the tex-file into a PDF.
And here is how I implemented it.
The template for the LaTeX-skeleton looks as follows (file named $DIARY/template.tex):
\input{./macros.tex} \begin{document} \title{} \maketitle Here goes the text \end{document}
The file $DIARY/macros.tex contains document and package definitions, that define the common properties for all tex-files, and hence a unique look for all resulting pdf-files.
Example:
\documentclass[paper=a5,pagesize=auto]{scrartcl} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[ngerman]{babel} \usepackage{amsmath} \usepackage{listings}
The script, that launches when typing diary is the following ($DIARY/diary.sh):
#!/bin/bash TODAY=$(date +"%Y-%m-%d") BASE=~/Dokumente/texs TEXFILE=$BASE/$TODAY.tex PDFFILE=$BASE/$TODAY.pdf if [ -f $TEXFILE ] then zenity --error --text "Tex-File $TEXFILE already exists!!!" else cp $BASE/template.tex $TEXFILE fi kate $TEXFILE & cd $BASE pdflatex $TEXFILE okular $PDFFILE &
Some notes:
- zenity simply pops up a dialog box with the given warning
- okular is my favorite PDF viewer - in fact it could be any other viewer
By the end of each year I might create a document named diary-201x.pdf, which includes all entries and is a nice compilation of my diary entries. For instance, this could be done with the pdftk. (pdftk *.pdf cat output diary-201x.pdf)
P.S.: You may wonder, why I'm mixing Gnome and KDE software. I'm working with Ubuntu and have some KDE-packages installed. Well, that's my environment, and I'm very fine with that. If you are Ubuntu-User, too, you will find all of the necessary software in the Ubuntu repositories (sudo apt-get install XXX, whereas XXX stands for kate, okular, zenity, pdftkm, etc.)
No comments:
Post a Comment