Thursday, April 24, 2008

Introduktionkursus til LaTeX

Den 30. april skal jeg afholde et introduktions kursus i latex for IDA på Ingeniør Højskolen i København. Her på denne side vil jeg samle henvisninger til de materialer der skal benyttes under kurset.


Forskellige ressourcer

Latex skabeloner
  1. Min nuværende latex skabelon, hent den her.
  2. En ældre skabelon, hent den her.
  3. En ældre skabelon til MAC, hent den her.
Latex referencer
  1. The not so short introduction to latex, link.
  2. Short math guide for latex, link.
  3. The comprehensive latex symbol list, link.
Slides til introduktionskurset
  1. Slides benyttet til kurset, hent det her.
  2. Kildekoden til de benyttede slides, hent det her.
Forskellige mindre latex opgaver
  1. Skrivning af matematik, hent det her.
  2. Overskrifter og indholdsfortegnelse, hent det her.
  3. Referencer og litteraturliste, hent det her.
  4. Lister i latex, hent det her.
  5. Spalter og figurer inde i teksten, hent det her.




Windows

Installing latex on windows
  1. Download MikTeX from here.
  2. Run the installer.
  3. Start -> All programs -> MikTeX ->
Installing a latex editor on windows

This requires that latex (eg. MikTeX) has been installed.
  1. Download TexnicCenter from: here
  2. Run the installer.
  3. Set path to your MikTeX installation (something like "C:\Programmer\MiKTeX 2.6\miktex\bin\")
  4. Select output profile: "LaTeX => PDF"
  5. Extract my template document and open the file doc\project.tex in TexnicCenter and try to compile it with pdflatex.
  6. During the compilation miktex will ask for permission to install some required packages (fancyhdr, listings, caption, subfig, pgf, xcolor, xkeyval)
  7. In case of trouble install the missing packages via: Start -> All program -> MikTeX 2.6 -> Browse packages
  8. Your document should now have been compiled, examine the generated .pdf file.

Linux

Installing latex on linux (ubuntu)
  1. Install the packages: texlive
Installing a latex editor on linux (ubuntu)
  1. Install kile

Thursday, April 17, 2008

Todo notes in Latex as a package

The package has been updated, find the new version at http://midtiby.blogspot.com/2008/07/todonotes-version-2008-07-28.html.

I have transformed the previously described script into a latex package (pheww, this is my first package, so there may exists some rough edges ...). The source for the package is given below.

The package currently takes three arguments
* disable = [true, false] if false the package will only define empty commands, so no output from the embedded todo commands are generated, but you document will compile
* color = [color values accepted by pgf] Defines the background color of the todonotes and the line connecting the todo note with the place it was inserted in the test.
* bordercolor = [color values accepted by pgf] Defines the border color of the todonotes.

I use the following line to import the package to a document.

\usepackage[
disable=false,
color=orange!80,
bordercolor=black]
{todonotes}

I hope that someone will find this usefull.

Henrik


======= begin: todonotes.sty ========
% Part: Identification
\ProvidesPackage{todonotes}

% Part: The package loading part
\RequirePackage{xkeyval}
\RequirePackage{hyperref}
\RequirePackage{tikz}

% Part: Initial code
\newcommand{\@backgroundcolor}{orange}
\newcommand{\@bordercolor}{black}

% Part: The declaration of options
\define@boolkey{todonotes.sty}%
[todo]{disable}{}
\define@key{todonotes.sty}%
{color}{\renewcommand{\@backgroundcolor}{#1}}
\define@key{todonotes.sty}%
{bordercolor}{\renewcommand{\@bordercolor}{#1}}
\ProcessOptionsX

% Part: The main code part
\iftododisable
\newcommand{\listoftodos}{}
\newcommand{\todo}{}
\else
\newcommand{\listoftodos}
{\section*{Todo list} \@starttoc{tdo}}
\newcommand{\l@todo}
{\@dottedtocline{1}{0em}{2.3em}}

\tikzstyle{notestyle} = [draw=\@bordercolor,
fill=\@backgroundcolor, text width = 3cm]
\tikzstyle{notestyleleft} = [notestyle]
\tikzstyle{connectstyle} = [draw = \@backgroundcolor, thick]

\newcommand{\todo}[1]{%
% Add to todo list
\addcontentsline{tdo}{todo}{\protect{#1}}%
%
% Remember where we are
\begin{tikzpicture}[remember picture, baseline=-0.75ex]%
\node [coordinate] (inText) {};%
\end{tikzpicture}%
%
% Make the margin par
\marginpar {% Draw note in right margin
\tikz[remember picture] \draw node[notestyle] (inNote) {#1};%
\begin{tikzpicture}[remember picture, overlay]%
\draw[connectstyle]
([yshift=-0.2cm] inText)
-| ([xshift=-0.2cm] inNote.west)
-| (inNote.west);
\end{tikzpicture}%
}%
}%
\fi
======= end: todonotes.sty ========

Sunday, October 7, 2007

Introduction to LaTeX

Thursday october the 11th, I will be teaching at an introductory course in latex. The course will be held at University of Southern Denmark at the campus in Odense. This blogpost will be used to gather information which is relevant for this course.

Windows

Installing latex on windows
  1. Download MikTeX from here.
  2. Run the installer.
  3. Start -> All programs -> MikTeX ->
Installing a latex editor on windows

This requires that latex (eg. MikTeX) has been installed.
  1. Download TexnicCenter from: here (wrong link given during the course here).
  2. Run the installer.
  3. Set path to your MikTeX installation (something like "C:\Programmer\MiKTeX 2.6\miktex\bin\")
  4. Select output profile: "LaTeX => PDF"
  5. Extract my template document and open the file doc\project.tex in Texmaker and try to compile it with pdflatex.
  6. During the compilation miktex will ask for permission to install some required packages (fancyhdr, listings, caption, subfig, pgf, xcolor, xkeyval)
  7. In case of trouble install the missing packages via: Start -> All program -> MikTeX 2.6 -> Browse packages
  8. Your document should now have been compiled, examine the generated .pdf file.
Linux

Installing latex on linux (ubuntu)
  1. Install the packages: texlive
Installing a latex editor on linux (ubuntu)
  1. Install kile
Other ressources

Latex templates
  1. My current latex template can be found here.
  2. A Mac edition of the template, grab it here.
Latex references
  1. The not so short introduction to latex, link.
  2. The comprehensive latex symbol list, link.
  3. Short math guide for latex, link.
Introduction presentation
  1. My introduction to LaTeX, grab it here.
  2. Source code for my introduction, here.

Friday, September 14, 2007

Todo notes in Latex

An updated version of the code below can be found at http://midtiby.blogspot.com/2008/05/updated-todonotes-package.html.

This is a description of how to place todo notes in your latex document, and how to collect the content of these in a structure like a table of contents (eg. a list of things todo)




A year and a half ago, when I wrote my bachelor report, I had a need to mark needed changes in the margin of a latex document. I wanted to place a note in the margin with a command like

\todo{Something that has to be done}

The solution was to use the marginpar command, in the definition below

\newcommand{\todo}[1]{\marginpar{#1}}

Later this approach was improved by generating a list of these todo items. The behavior of \todo was now to print something in the margin and add an item in the todolist.

\newcommand{\todo}[1]{
\addcontentsline{tdo}{todo}{\protect{#1}}
\marginpar{#1}
}

Additionally I defined a command to generate the list of todos.

\makeatletter \newcommand \listoftodos{\section*{Todo list} \@starttoc{tdo}}
\newcommand\l@todo[2]
{\par\noindent \textit{#2}, \parbox{10cm}{#1}\par} \makeatother

Now the list of todo's could be inserted by using the command

\listoftodos

For some time ago, I began reading about the portable graphics format (PGF) and wanted to tinker a bit with it. PGF is a great tool for generating graphics for latex documents (you can find a lot of examples at www.fauskes.net/pgftikzexamples/.) Especially the possibility of overlaying your existing text with graphics were interesting.

One of the results is this improved todo note code for latex.

\newcommand{\todo}[1]{
% Add to todo list
\addcontentsline{tdo}{todo}{\protect{#1}}
%
\begin{tikzpicture}[remember picture, baseline=-0.75ex]
\node [coordinate] (inText) {};
\end{tikzpicture}
%
% Make the margin par
\marginpar{
\begin{tikzpicture}[remember picture]
\definecolor{orange}{rgb}{1,0.5,0}

\draw node[draw=black, fill=orange, text width = 3cm] (inNote)
{#1};
\end{tikzpicture}
}
%
\begin{tikzpicture}[remember picture, overlay]
\draw[draw = orange, thick]
([yshift=-0.2cm] inText)
-| ([xshift=-0.2cm] inNote.west)
-| (inNote.west);
\end{tikzpicture}
%
}

Currently there are a minor glitch of the code, at the location of the \todo command latex inserts a large amount of space, which I would like to avoid.

I use this piece of code myself, but if any of you would like to use it you should be welcome. Comments or ideas for improving the code are of cause welcome

Henrik