2010年10月25日 星期一

GasTex Example(For Automata)

http://www.liacs.nl/~hoogeboo/praatjes/gastex/

GasTeX (Graphs and Automata Simplified in TeX, by Paul Gastin) is a package for drawing figures with a LaTeX interface and the help of Postscript. Everyone that needs to draw automata in his LaTeX documents on a regular basis should have a look at this package.
The examples below are mainly to remind me of the possible settings for figures I sometimes need.


\begin{figure}[H]
  \begin{center}
    \unitlength=4pt
    \begin{picture}(15, 28)(0,-10)
      \gasset{Nw=5,Nh=5,Nmr=2.5,curvedepth=3}
      \thinlines
      \node(A0)(7.5,0){$0$}
      \node[Nmarks=i,iangle=90](A1)(0,13){$1$}
      \node[Nmarks=if,iangle=90,fangle=90](A2)(15,13){$2$}
      \drawloop[loopangle=180](A1){$a$}
      \drawloop[loopangle=0](A2){$b$}
      \drawedge(A1,A2){$a$}
      \drawedge(A2,A1){$b$}
      \drawedge(A2,A0){$a$}
      \gasset{curvedepth=-3}
      \drawedge[ELside=r](A1,A0){$b$}
      \drawloop[loopangle=270](A0){$a, b$}
    \end{picture}
  \end{center}
  \caption{La complétion de l'automate.}
\end{figure}
Example of GasTeX output



Code
binary relation

Code
binary tree (post order)

Code
undirected graph (a)

Code
undirected graph (b)

Code
undirected graph (c - linear)

Code
fsa (final 0 or even 1's)

Code
fsa (subword 00 or even 1's)

Code
fsa (ends in a - - , deterministic)

Code
cube (strings Hamilton dist 1)

Code
CMB Euler path

Code
CMB probes (A..G) and clones (1..6)

Code
CMB PQ trees

Code
Hilbert curve (tiles)

2010年10月21日 星期四

[轉錄] Latex Matrix

http://en.wikibooks.org/wiki/LaTeX/Mathematics



Matrices and other arrays in LaTeX

Matrices and other arrays are produced in LaTeX using the \textbf{array} environment. For example, suppose that we wish to typeset the following passage:
[GIF Image]
This passage is produced by the following input:
The \emph{characteristic polynomial} $\chi(\lambda)$ of the
$3 \times 3$~matrix
\[ \left( \begin{array}{ccc}
a & b & c \\
d & e & f \\
g & h & i \end{array} \right)\] 
is given by the formula
\[ \chi(\lambda) = \left| \begin{array}{ccc}
\lambda - a & -b & -c \\
-d & \lambda - e & -f \\
-g & -h & \lambda - i \end{array} \right|.\] 
First of all, note the use of \left and \right to produce the large delimiters around the arrays. As we have already seen, if we use
\left) ... \right)
then the size of the parentheses is chosen to match the subformula that they enclose. Next note the use of the alignment tab character & to separate the entries of the matrix and the use of \\ to separate the rows of the matrix, exactly as in the construction of multiline formulae described above. We begin the array with \begin{array} and end it with \end{array}. The only thing left to explain, therefore, is the mysterious {ccc} which occurs immediately after \begin{array}. Now each of the c's in {ccc} represents a column of the matrix and indicates that the entries of the column should be centred. If the c were replaced by l then the corresponding column would be typeset with all the entries left-justified, and r would produce a column with all entries right-justified. Thus
\[ \begin{array}{lcr}
\mbox{First number} & x & 8 \\
\mbox{Second number} & y & 15 \\
\mbox{Sum} & x + y & 23 \\
\mbox{Difference} & x - y & -7 \\
\mbox{Product} & xy & 120 \end{array}\] 
produces
[GIF Image]

We can use the array environment to produce formulae such as
[GIF Image]
Note that both columns of this array are set flush left. Thus we use {ll} immediately after \begin{array}. The large brace is produced using\left\{. However this requires a corresponding \right delimiter to match it. We therefore use the \emph{null delimiter} \right. discussed earlier. This delimiter is invisible. We can therefore obtain the above formula by typing
\[ |x| = \left\{ \begin{array}{ll}
         x & \mbox{if $x \geq 0$};\\
        -x & \mbox{if $x < 0$}.\end{array} \right. \] 

[轉錄]Latex image inside table

Pictures do not necessarily have to be placed inside the figure environment, but can perfectly be included inside table cells.

The advantage is, you can without any effort arrange a series of images in a matrix and individually scale them.

And here is how you would do it: You first need the graphicx package to include graphics:

\usepackage{graphicx}

Now you can directly start with your table environment and add graphics:

\begin{table}[ht]

\caption{A table arranging images}
\centering
\begin{tabular}{cc}
\includegraphics[scale=1]{graphic1}&\includegraphics[scale=1]{graphic2}\\
\newline
\includegraphics[scale=1]{graphic3}&\includegraphics[scale=1]{graphic4}\\
\end{tabular}
\label{tab:gt}

\end{table}%

Note: In order to have visual borders, you would have \hline instead of \newline and use horizontal bars in the column definition of the tabular environment (“|c|c|” instead of “cc”).

The downside of this technique is obvious, you do not have access to features provided by the figure environment like a label or caption. Nevertheless, it might still come in handy in certain situations.

Note: The figures will not appear in the \listoffigures index, for the reason mentioned above.

2010年10月20日 星期三

[轉錄]Lists: Enumerate, itemize, description and how to change them


Latex distinguishes between three different enumeration/itemization environments. Each of them provide four levels, which means you can have nested lists of up to four levels.
Enumerate:
\begin{enumerate}
\item ...
\end{enumerate}
The enumerate-environment is used to create numbered lists.
If you like to change the appearance of the enumerator, the simplest way to change is to use the enumerate-package, giving you the possibility to optionally choose an enumerator.

\usepackage{enumerate}
...
\begin{enumerate}[I]%for capital roman numbers.
\item
\end{enumerate}
\begin{enumerate}[(a)]%for small alpha-characters within brackets.
\item
\end{enumerate}
Itemize:
\begin{itemize}
\item ...
\end{itemize}
Itemization is probably the mostly used list in Latex. It also provides four levels. The bullets can be changed for each level using the following command:
\renewcommand{\labelitemi}{$\bullet$}
\renewcommand{\labelitemii}{$\cdot$}
\renewcommand{\labelitemiii}{$\diamond$}
\renewcommand{\labelitemiv}{$\ast$}
Amongst the more commonly used ones are $\bullet$ (\bullet), $\cdot$ (\cdot),$\diamond$ (\diamond), $-$ (-), $\ast$ (\ast) and $\circ$ (\circ).
Description:
\begin{description}
\item[] ...
\end{description}
The description list might be the least known. It comes in very handy if you need to explain notations or terms. Its neither numbered nor bulleted.
Example:
\begin{description}
\item[Biology] Study of life.
\item[Physics] Science of matter and its motion.
\item[Psychology] Scientific study of mental processes and behaviour.
\end{description}
And in a PDF it would look like this:
Example of a description list.
Example of a description list.
Note:
The space between different items can be controlled with the \itemsep command (can only be added just after “begin”):
\begin{itemize}\itemsep2pt
\item
\end{itemize}

2010年10月19日 星期二

latex中文目錄


當在編輯目錄時
要讓本來是英文的目錄標題變成中文
只需重新命名就好了
\renewcommand\contentsname{目錄}
\renewcommand\listfigurename{圖目錄}
\renewcommand\listtablename{表目錄}
LaTex 預設生成的目錄會長這樣1 簡介
1.1 研究背景
1.2 研究動機
為了要符合中文樣式
將 "1 簡介" 改成 "第一章 簡介"
可以這樣改寫
%使用 titletoc 這一個 package \usepackage{titletoc}\titlecontents{chapter}
[0em]
{}
{第\CJKnumber{\thecontentslabel}章~~}
{}{\titlerule*{.}\contentspage}
\titlecontents{section}
[4em]
{}
{\contentslabel{2em}}
{}{\titlerule*{.} \contentspage}
\titlecontents{subsection}
[8em]
{}
{\contentslabel{3em}}
{}{\titlerule*{.} \contentspage}
此外一般我們中文的圖、表目錄
都會習慣寫成
圖1.1
表1.1
而 LaTex 預設是沒有那些圖、表的文字,只有顯示數字
因此必須要修改一下
\newcommand{\loflabel}{圖}
\newcommand{\lotlabel}{表}
在圖目錄的地方插入這二行
\renewcommand{\numberline}[1]{\loflabel~#1\hspace*{1em}}
\listoffigures
在表目錄的地方插入這二行
\renewcommand{\numberline}[1]{\lotlabel~#1\hspace*{1em}}
\listoftables

解決index的中文問題


> i run latex on the file.. it runs file; then i run makeindex on the
> file, it runs fine.  then i run latex on the file again, and it
> starts complaining.

makeidx.sty uses \write, (not \immediate\write) for index entries
which means that the output to the index file is delayed until the
whole page is output.  You thus have to do two things.

  . Move \printindex into a CJK environment

  . Insert \newpage after \printindex.

Below is my (slightly changed) version which works just fine.


    Werner


======================================================================


\documentclass[12pt]{article}

\usepackage{CJKutf8}
\usepackage{pinyin}
\usepackage[vietnam]{babel}
\usepackage{makeidx}


\makeindex


\begin{document}

\begin{CJK}{UTF8}{bsmi}

我是美國人\index{美國 mỹ quốc}

我不會說中文\index{cannot speak}

\printindex
\newpage

\end{CJK}

\end{document}

%%% Local Variables:
%%% coding: utf-8
%%% mode: latex
%%% TeX-master: t
%%% End:

2010年10月16日 星期六

2010年10月14日 星期四