2009-09-20

Using LaTeX CJK package to use three languages at once

(The English translation is below the German text.)

Normalerweise verwende ich platex um Japanisch zu schreiben. Damit kann ich einen japanischen und einen englischen Text zusammen in einem LaTeX Dokument verfassen. Aber als ich einen deutschen Text unter Verwendung des Babel Pakets hinzugef"ugt habe, wurde die folgende Warnung angezeigt:

Package babel Warning: No hyphenation patterns were loaded for the language `ngerman'.

Ich habe im Internet danach gesucht, ob jemand diese drei Sprachen gleichzeitig verwendet hat, aber ich konnte nichts dazu finden. (In der Vergangenheit gab es ein "ahnliches Problem auf das sich die Warnung bezogen hat. Aber dieses wurde schon gel"ost.)

Es scheint, als ob einige Dateien mit initex erneut kompiliert werden m"ussen. Das platex Paket von Ubuntu machte dies jedoch nicht. Ich vertraue immer auf die Worttrennung von LaTeX. Aber gestern hat meine Tandempartnerin bemerkt, dass der Bindestrich bei ,,in meiner Heimatstadt'' als ``in mein-er Heimatstadt'' gesetzt wird. Das ist falsch. Ich habe herausgefunden, dass das CJK Paket von LaTeX dies korrekt behandeln kann. Diese LaTeX Datei ist ein Beispiel daf"ur, Japanisch, Deutsch und Englisch in einem LaTeX Dokument zu kombinieren.

[1] http://blogs.fsfe.org/ciaran/?p=150+k

Thanks to Leo to proofreading in the German text.


English version

I usually use platex for writing Japanese. I can have a Japanese and English mixed document by platex, but when I added a German text to such document with the babel package, the following error message is shown up.

Package babel Warning: No hyphenation patterns were loaded for the language `ngerman'.

I could not find a solution on the web that someone uses Japanese, English, and German at once in a LaTeX document. (In the past, there was a problem related with this error, but it has been solved.)

It seems I need to recompile some files with initex. Ubuntu's package seems not to do this. I always rely on the LaTeX about the hyphenation. But, yesterday my tandem partner noticed that ``in meiner Heimatstadt'' is hyphenated as ``in mein-er Heimatstadt.'' This is not correct. I found LaTeX's CJK package can handle this situation. This is a sample file of writing Japanese, German, and English.


LaTeX source

%
%
%defparentheses 【 】
%defswap |
%defdelete /
%defcomment ;
%defescape
%deforder older-first
%defversion 0.9.5-current

\documentclass[a4paper]{article}
\usepackage{CJK} % CJK latex
\usepackage{amsmath}
\usepackage{a4wide}
\usepackage{graphicx}
\usepackage{cite}
%\usepackage{hyperref} % Unfortunately, this does not work in CJK
\usepackage[ngerman,american]{babel}
\sloppy

\begin{document}

\begin{CJK*}[dnp]{JIS}{min}
\title{日本語ドイツ語英語混在の \LaTeX 文書}
\date{2009-9-9(Wed)}
\author{S.U.}

\twocolumn[\maketitle]

\section{CJK パッケージを利用して三ヶ国語を同時利用する}

私が利用している日本語の\LaTeX\ は \texttt{platex} である.
\texttt{platex} で日本語と英語を混在させるのは問題がないが,ドイツ語を利
用しようとすると,
\begin{verbatim}
Package babel Warning: No hyphenation
patterns were loaded for the language
`ngerman'
\end{verbatim}
というエラーがでる.Web 上を探したがこの日本語英語ドイツ語の三言語を同時
に利用する方法というのはどうもみつからなかった.(過去に Ubuntu にはこの
エラーに関連する問題があったが現在は解決されている.)

これを解決するには \texttt{initex} によっていくつかのファイルを
recompile しないといけないようである.Ubuntu の \texttt{platex} の
package はおそらく babel を考慮していない.私は hyphenation は全て \TeX
まかせなのだが,この場合,in meiner Heimatstadt が in \mbox{mein-er}
Heimatstadt と hyphenation されてしまうことがあり,私の tandem partner に
これはできない,と指摘されてしまった.確かにこういう部分が自動でなされる
ことが \TeX を使っていて便利な点なのに,間違いをされるのは困る.そこで,
いくつか試してみた結果,\LaTeX\ の CJK package ならできるようであ
る.このファイルは CJK package を使って,日本語,ドイツ語,英語を同時に利
用するサンプルファイルである.


\selectlanguage{american} % Use american
\section{Using CJK package to use three languages at once}

I usually use \texttt{platex} for writing Japanese. I can have a
Japanese and English mixed document by \texttt{platex}, but when I added
a German text to such document with the babel package, the following
error message is shown up.
\begin{verbatim}
Package babel Warning: No hyphenation
patterns were loaded for the language
`ngerman'.
\end{verbatim}
I could not find a solution on the web that someone uses Japanese,
English, and German at once in a \LaTeX\ document. (In the past,
there was a problem related with this error, but it has been solved.)

It seems I need to recompile some files with initex. Ubuntu's package
seems not to do this. I always rely on the \LaTeX\ about the hyphenation.
But, yesterday my tandem partner noticed that ``in meiner Heimatstadt''
is hyphenated as ``in \mbox{mein-er} Heimatstadt.'' This is not correct. I
found \LaTeX's CJK package can handle this situation. This is a sample
file of writing Japanese, German, and English.


\selectlanguage{ngerman} % Use new-german
\section{Die Verwendung des CJK Pakets um drei Sprachen gleichzeitig zu
verwenden}

Normalerweise verwende ich \texttt{platex} um Japanisch zu
schreiben. Damit kann ich einen japanischen und einen englischen Text
zusammen in einem \LaTeX\ Dokument verfassen. Aber als ich einen
deutschen Text unter Verwendung des Babel Pakets hinzugef"ugt habe,
wurde die folgende Warnung angezeigt:
\begin{verbatim}
Package babel Warning: No hyphenation
patterns were loaded for the language
`ngerman'.
\end{verbatim}
Ich habe im Internet danach gesucht, ob jemand diese drei Sprachen
gleichzeitig verwendet hat, aber ich konnte nichts dazu finden. (In der
Vergangenheit gab es ein "ahnliches Problem auf das sich die Warnung
bezogen hat. Aber dieses wurde schon gel"ost.)

Es scheint, als ob einige Dateien mit \texttt{initex} erneut kompiliert
werden m"ussen. Das \texttt{platex} Paket von Ubuntu machte dies jedoch
nicht. Ich vertraue immer auf die Worttrennung von \LaTeX. Aber
gestern hat meine Tandempartnerin bemerkt, dass der Bindestrich bei ,,in
meiner Heimatstadt'' als ``in \mbox{mein-er} Heimatstadt'' gesetzt wird. Das
ist falsch. Ich habe herausgefunden, dass das CJK Paket von \LaTeX\
dies korrekt behandeln kann. Diese \LaTeX\ Datei ist ein Beispiel
daf"ur, Japanisch, Deutsch und Englisch in einem \LaTeX\ Dokument zu
kombinieren.

\subsection*{Reference}
\verb+[1] http://blogs.fsfe.org/ciaran/?p=150+k

\subsection*{Acknowledgements}
Thanks to L. to proofreading in the German text.

\end{CJK*}
\end{document}

2009-09-15

Logically speaking....

It is election time in Germany. I can find quite a lot of notice boards. I was surprised that one political party's motto is

"More tax to everyone"

This party got a lot of votes at Saarland recently. Actually, they did not directory say it, but they have two slogans:

1. Reichtum besteueren (Tax the rich: Front side)

2. Reichtum fuer alle (Rich for everyone: Back side)

"More tax to rich people" and "Everyone should be rich", therefore, "More tax to everyone." Am I missing something?

My friend L. told me this.


Front side


Back side

2009-09-09

cool matrix (5)

Finally I would like to talk about cool matrices.

Let's think about a three dimensional vector [x1 x2 x3]' =


x1
[x2]
x3.


(Here ' means transpose.) The vector of difference of each term is [(x1 - 0) (x2 - x1) (x3 - x1)]'. Let's think about a matrix A that makes this difference in the right hand side. I will tell you why we think such a matrix. A is


[ 1 0 0
-1 1 0
0 -1 1].


Let's check it out.


[ 1 0 0 [x1 [ x1 - 0
-1 1 0 x2 = x2 - x1
0 -1 1] x3] x3 - x2 ]


For instance, use [x1 x2 x3]' = [1 4 9]',


[ 1 0 0 [1 [ 1
-1 1 0 4 = 3
0 -1 1] 9] 5 ].


The right hand side is the difference of each term. By the way, this matrix has its inverse matrix B,


[1 0 0
1 1 0
1 1 1].


Let's compute A B,


[ 1 0 0 [1 0 0 [ 1 0 0 [1 0 0
-1 1 0 1 1 0 = (-1+1) 1 0 = 0 1 0
0 -1 1] 1 1 1] (-1+1) (-1+1) 1] 0 0 1].


Therefore, A^{-1} = B. Please be patience a bit more. Let's look into what is B.


[ 1 0 0 [x1 [x1
Bx = 1 1 0 x2 = x1 + x2
1 1 1] x3] x1 + x2 + x3]


You see B is adding terms. A does difference and B does sum. I was surprised here. The idea ``difference'' belongs more to calculus, compare to linear algebra. In calculus, difference is d/dx. The inverse operation of difference is integral (\int). These matrices are:

A ... d/dx
B ... \int

and we know A^{-1} = B.

A^{-1} = {d/dx}^{-1} = B = \int
===> {d/dx}^{-1} = \int

Matrix behaves an operator, now we think matrix A is a differential operator and B is an integral operator, then these are inverse operation each other. I hope you can see why I surprised. We can see an analogy of the fundamental theorem of calculus in a matrix operation. So I think these matrix A and B are cool matrices. I might be only one to think so, I can imagine many people don't agree with me... Well.


This matrix story is in the book: Gilbert Strang, ``Introduction to LINEAR ALGEBRA''. This is my personal hot book. He describes what is the inverse of matrix with calculus analogy. That is fantastic and I like his book.

For the people who is lazy as me, here is a octave code.


--- BEGIN diff_and_int.m ---
a = [1 0 0; -1 1 0 ; 0 -1 1]
inv(a)
--- END diff_and_int.m ---


When you run this code with typing 'octave diff_and_int.m', you will see
the matrix B.

cool matrix (4)

There are so many applications of this linear operation. For example, one day's total sales of a supermarket can be computed in the same way:

price of item 1 * number of sold of item 1 + price of item 2 * number of sold of item 2 + ...

Again, price of item 1 * price of item 2 has no meaning here and therefore, we should not do that.

Matrix is useful when we want to perform this kind of operation. Of course we can use matrix (so many) different ways, even so this is still useful.

Until here, I hope this is understandable for a junior high school student. But, I realize I could not reach the entitled theme, a cool matrix, in this pace. Then, I will skip several topics, like, what is the relationship between a linear operation and a matrix. I am going to talk about a cool matrix in the next article. The audience would be a bit limited. I assume you know what is matrix or vector and how to write down this language, also can speak a bit. So I assume the audience is a
high school student or more.