With the right plugin you can use LaTeX to write your formulas in WordPress!
This is a nice one from my thesis:
And the alternative formulation over edges instead of words and with only two similarities (Fürstenau and Lapata, 2012):
Cool, eh?
With the right plugin you can use LaTeX to write your formulas in WordPress!
This is a nice one from my thesis:
And the alternative formulation over edges instead of words and with only two similarities (Fürstenau and Lapata, 2012):
Cool, eh?
Timidity is a little commandline program to play midi files on Linux:
timidity Was-soll-das-bedeuten.midi
My midi is a choir score with three voices and the output of timidity looks like this:
Playing Was-soll-das-bedeuten.midi MIDI file: Was-soll-das-bedeuten.midi Format: 1 Tracks: 6 Divisions: 384 Sequence: control track Text: creator: Text: GNU LilyPond 2.18.2 Track name: :Soprano Track name: :Alto Track name: :Men
With the above standard command all voices are played together. To practice something it is sometimes nice to have only your own voice alone, you can do this by quieting/muting all voices except your own. The voices to be muted are listed after the option -Q separated by comma. The value 0 means all voices, the number of the other voices is given by their order in the output. So in the file I have, Soprano would be 1, Alto 2 and the men’s voices 3. Including the number mutes the voice, including it with a minus sign plays it. So let’s say I want to practice the alto voice, I’ll mute all but voice 2:
timidity -Q 0,-2 Was-soll-das-bedeuten.midi
It’s also simple to transpose stuff, this will play the song two semitones higher:
timidity -K 2 Was-soll-das-bedeuten.midi
GIMP is not your typical program for drawing, but is is the only thing related to graphics that is installed on my linux. So I have this screenshot and I want to draw a red rectangle around the part that needs to be clicked. This is how:
This is probably a very old hat for Linux-savy people. You can use ssh to execute commands on a remote server, just pass them on as an additional argument:
ssh me@my.server.de "cd bla ; ls ; python test.py "
I use double quotes (“) istead of single quotes (‘) to interpret variables. Different commands are separated with semicolon (;). You can use any command you like, but for some reason when I call some GUI I don’t get the output on the command line until the window is closed.
Dolphin allows you to connect to folders on other machines per SSH, but there is no option to specify a key file. But you can add the key to your general SSH configuration (with the added benefit that you also won’t have to specify the keyfile anywhere else, no more -i on the command line!). This is how it works:
~/.ssh/myidentity_rsa.~/.ssh/config and add the lines
Host myhost.net HostName myhost.net IdentityFile ~/.ssh/myidentity_rsa
fish://user@myhost.net/path/to/folder/ into the location bar.Done!
Yesterday I posted about creating bar charts with TikZ and pgfplots.
Today I want to present a command to make the bars of one data series (i.e., one of my systems) appear one after the other on a beamer LaTeX slide.
This is the code to put into your preamble:
\newcounter{MyNextSlide}
\newcounter{MyNextNextSlide}
\newcommand{\addplotoverlay}[5][]{
\setcounter{MyNextSlide}{#5}
\stepcounter{MyNextSlide}
\setcounter{MyNextNextSlide}{\theMyNextSlide}
\stepcounter{MyNextNextSlide}
\alt<#5->{\only<#5->{\alt<\theMyNextSlide->{\alt<\theMyNextNextSlide->{
\addplot+ [ybar,#1] coordinates {#2 #3 #4};
}{
\addplot+ [ybar,#1] coordinates {#2 #3};
}}{
\addplot+ [ybar,#1] coordinates {#2};
}}}{
\addplot+ [ybar,#1] coordinates {(PI,0)}; % + don't show zero values in plot
}
}
Usage (‘first slide’ refers to the slide on which value 1 should first appear, it will stay and the slide afterwards will add value 2, the slide after that will add value 3):
\addplotoverlay [color or other options] {value 1}{value 2}{value 3}{first slide}
This depends on there being three data points in a data series and I have hardcoded the x coordinate PI. You’ll probably need to adjust this before you are able to do something useful with this code.
I have four systems to compare (baseline, minimal, window, syntax) on three different tasks (let’s call them PI, AI and AC). I want a bar chart (similar to this example). We of course use TikZ and pgfplots and there is ybar to get a bar chart. The outer bars are cut off, so we need to add a little space on both sides with enlarge x limits. We can play around with the axes, the height and the width of the plot and the legend, but you can look at other examples for this, I’ll focus on two things here.
First, I would like to have the three tasks side by side with a nice name. In TikZ we can use symbolic x coordinates for this, we just give them some names and can then use them like any other x coordinate, e.g., to put a data point at (PI, 50). We can give the coordinates labels that are nicer to read with xticklabels. Usually there will be ‘ticks’ (i.e., markers on the x axis) somewhere randomly, to get only for each x-axis label/task, use xtick=data.
symbolic x coords={PI, AI, AC},
xticklabels={Pred. ident., Arg. ident., Arg. class.},
xtick=data,
Second, I would like to have the numbers above the bars with one decimal place. We can get the numbers with these two lines (the first one gives the numbers, as they are too big the second line adjusts the font size):
nodes near coords={\pgfmathprintnumber[fixed zerofill,fixed,precision=1]{\pgfplotspointmeta}}
every node near coord/.append style={font=\tiny}
To get rid of zeros, we can replace the second line with
every node near coord/.append style={
check for zero/.code={
\pgfmathfloatifflags{\pgfplotspointmeta}{0}{
\pgfkeys{/tikz/coordinate}
}{}
},
check for zero, font=\tiny},
So this is my final axis style:
\pgfplotsset{resultsplot/.style={
axis x line*=bottom,
axis y line=left,
ybar,
symbolic x coords={PI, AI, AC},
xticklabels={Pred. ident., Arg. ident., Arg. class.},
xtick=data,
enlarge x limits=0.2,
nodes near coords={\pgfmathprintnumber[fixed zerofill,fixed,precision=1]{\pgfplotspointmeta}},
every node near coord/.append style={
check for zero/.code={
\pgfmathfloatifflags{\pgfplotspointmeta}{0}{
\pgfkeys{/tikz/coordinate}
}{}
}, check for zero, font=\tiny},
area legend,
legend style={at={(0.5,-0.12)},
anchor=north,legend columns=-1},
}
}
And now we can get the actual graph that uses this axis style. Each plot represents a different system (the numbers are F1 scores):
\begin{tikzpicture}
\begin{axis}[resultsplot]
\addplot+ [ybar,green] coordinates {(PI, 67.8) (AI, 30.6) (AC, 20.2)};
\addlegendentry{Baseline}
\addplot+ [ybar,blue] coordinates {(PI, 78.6) (AI, 21.2) (AC, 16.5)};
\addlegendentry{Minimal system}
\addplot+ [ybar,orange] coordinates {(PI, 80.0) (AI, 44.2) (AC, 36.6)};
\addlegendentry{Window}
\addplot+ [ybar,red] coordinates {(PI, 80.1) (AI, 54.2) (AC, 44.8)};
\addlegendentry{Syntax}
\end{axis}
\end{tikzpicture}
Have fun!
More strange problems, still teaching LaTeX. So I wanted to teach people how to get text or code formatted exactly as they type it with the verbatim environment. This is the part of code I wanted to use as an example:
\begin{verbatim}
text inside a verbatim environment
is printed \emph{exactly} as you\\
type it ! % no comment!
\end{verbatim}
What I usually do is I have a block that shows the code they have to write and then the result. And of course for showing the code they need to write, I use verbatim. So can you include verbatim inside verbatim?
Well, yes you can, but of course you cannot include \end{verbatim}, as this would be interpreted as ending the verbatim environment. So I had to add this separately afterwards, using \verb (inline verbatim). Voila:
\begin{block}{What you write}
\begin{verbatim}
\begin{verbatim}
text inside a verbatim environment
is printed \emph{exactly} as you\\
type it ! % no comment!
\end{verbatim}
\verb|\end{verbatim}|
\end{block}
Now there’s only a small problem, namely that there is some spacing after the environment, so it seems like there is an empty line between the end of the verbatim text and the \end{verbatim}. For this example it doesn’t matter, I use it to show them that empty lines are also printed exactly as they are given.
But next example is how to include verbatim inside a beamer frame. The example code I wanted to show inside the usual verbatim environment:
\begin{frame}[fragile]
\begin{verbatim}
test
\end{verbatim}
\end{frame}
So you see that here I don’t really want an empty line between \end{verbatim} and \end{frame}. So my final hacky solution jumped back up over that space after the environment:
\begin{block}{What you write}
\begin{verbatim}
\begin{frame}[fragile]
\begin{verbatim}
test
\end{verbatim}
\vspace{-0.9\baselineskip}
\verb| \end{verbatim}|\\
\verb|\end{frame}|
\end{block}
Which works fine, but the more easy solution is probably this one (or use lstlisting or any other code-environment):
\begin{block}{What you write}
\verb|\begin{frame}[fragile]|\\
\verb| \begin{verbatim}|\\
\verb| test|\\
\verb| \end{verbatim}|\\
\verb|\end{frame}|
\end{block}
Another strange problem. I am teaching LaTeX and I usually have slides that say “write this” and “get this”, e.g., write \textbf{bold text} and get bold text.
So I wanted to do the same for the part where I teach beamer. Of course my slides are beamer slides, so I was curious what would happen if I simply include a title page or a table of content inside a minipage. Yes, it works, it inserts the part with the title respectively the table of contents. Of course what is missing is the frame layout, so I had to do a bit of adjusting there. But in the end I have a miniature version of the actual title page and table of content right there in the slide. This is how it works:
First, I used a minipage to get the frame aspect ratio right:
\begin{minipage}[c][0.7\textwidth][c]{\textwidth}
\end{minipage}
Around that a resizebox so that it comfortably fits onto my page below the code that explains how to do it, and an fbox to get some “frame feeling”.
\fbox{\resizebox{0.4\textwidth}{!}{
\begin{minipage}[c][0.7\textwidth][c]{\textwidth}
\end{minipage}
}}
And basically that’s it for the title page, only a bit more space below the text:
\fbox{\resizebox{0.4\textwidth}{!}{
\begin{minipage}[c][0.7\textwidth][c]{\textwidth}
\titlepage
\vfill
\end{minipage}
}}
For the table of contents I had to re-make the frame layout with the navigation bars and the frametitle. The theme is Madrid, which is pretty simple, so I only had to do a blue bar on top and another one at the bottom. For that I used a beamercolorbox which I guess is also used in the theme itself. The values for height and the rest are pure trial and error. I didn’t include the title, author, date etc. at the bottom, although that shouldn’t be too difficult.
\fbox{\resizebox{0.4\textwidth}{!}{
\begin{minipage}[c][0.7\textwidth][c]{\textwidth}
\vspace{-0.55\baselineskip}
\begin{beamercolorbox}[dp=1ex, ht=3ex, wd=1.065\textwidth]{frametitle}
\usebeamerfont{frametitle}Outline
\end{beamercolorbox}
\vspace{\baselineskip}
\vfill
\tableofcontents
\vfill
\begin{beamercolorbox}[ht=1.5ex, wd=1.065\textwidth]{frametitle}
\end{beamercolorbox}
\vspace{-0.6\baselineskip}
\end{minipage}
}}
Maybe not useful, but really cool to have on the slides!
Your typical LaTeX document imports two packages right at the beginning:
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
What do they do?
fontenc choses an output font for encoding characters. This is important for special characters to have correct hyphenation, ligatures and kerning. Also if you use special characters and want to copy them out of the pdf, when the package is missing you will get wrong results. For example, an “ä” will become “a” plus diacritics instead of just one single letter. Also some other characters may give unexpected results. T1 contains characters for most European languages.
inputenc allows the user to input special characters (like ä, ß, ñ) directly instead of escaping them. This is very nice if you are writing in a language other than English. The value should match the encoding with which the file has been written. If you have a file encoding that’s different from what you specify for inputenc, you will get errors similar to “input character XYZ is not defined”. You should always write all of your documents in UTF-8 nowadays, so that would be the usual value.
It is best to call fontenc first and then inputenc (though I have read conflicting information on that and I haven’t really seen a good reason for it).