2010年4月8日 星期四

amscd

作者: hantis (呢呢是豬) 看板: Hantis
標題: [隨寫] Note: amscd
時間: Thu Apr  8 11:54:55 2010


   This is an extremely useful package for communative diagrams,
   such as

      after 10 years
   A ----------------> B

   The above example can be obtained by

   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   ...
   \usepackage{amscd}
   ...

   \[
   \begin{CD}
   A @>\text{after 10 years}>> B
   \end{CD}
   \]
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   Note that the CD environment must be inside the math mode.
   So \begin{align*}\begin{CD} XXX \end{CD}\end{align*} is ok,
   and so is $\begin{CD} XXX \end{CD}$.

2010年4月1日 星期四

jpg for latex

作者: hantis (呢呢是豬) 看板: Hantis
標題: [隨寫] Note: jpg for latex
時間: Thu Apr  1 09:50:22 2010

This note was written long time ago but I didn't post on my board.
Here it goes:
==================================================================
bmeps是將點陣圖如jpg png等
轉成eps或ps圖的driver
直接在黑黑的DOS視窗執行就可以
例如:
bmeps XXX.jpg XXX.ps
就可以把XXX.jpg轉出一張XXX.ps
接著就可以用熟悉的方法來插入圖
然後latex -> dvips -> ps2pdf
不會有問題

不過這個轉圖法會是黑白的
要轉出彩色的則多下個 -c

bmeps -c XXX.jpg XXX.ps
這樣的ps圖就是彩色的
只是這樣的ps圖好像會很大
爛爛的解析度就會到1MB以上

另外一個方法更好
在吳聰穎、吳聰慧的書有提
不過不是很完全
這個方法
可以用\includegraphics{XXX.jpg}直接來
直接執行latex的話會掛掉
因為它需要bounding box
所以要用這個方法的話
得先bmeps -b XXX.jpg XXX.bb
這樣就會generate出XXX.bb這個宣告bounding box的檔
(其實這個bounding box也可以直接下
例如\includegraphics[bb=0 0 300 400,width=5cm,...]{XXX.jpg}
可是這個方法好像不太好)
有了bb檔之後
還要在PREAMBLE下
\DeclareGraphicsRule{.jpg}{eps}{.bb}{}
這樣
latex就OK

這樣子compile出來的dvi是OK的
但是直接dvips會把彩色圖弄成黑白的
這時候要再多下-I c
dvips這個driver有很多option
其指令格式是dvips [option] filename
其中[option]可以有很多
有一個網站有summarize
總之
dvips -I c filename
即可把filename.dvi成功轉成彩色的filename.ps
當然啦
如果本來就沒有jpg圖檔
直接dvips filename是沒有問題的

小結:
欲放入jpg之點陣圖檔最好的方法
1) PREAMBLE放入這行指令
\DeclareGraphicsRule{.jpg}{eps}{.bb}{}
2) 插入圖:
\includegraphics[...]{XXX.jpg}
3) 在Command Prompt製造XXX.bb的bounding box檔:
bmeps -b XXX.jpg XXX.bb
4) 開始compile以及轉檔:
latex main
dvips -I c main
ps2pdf main.ps

要在beamer的title page放圖的指令:
\titlegraphic{...}
例如
\titlegraphic{\includegraphics[width=2cm]{XXX.jpg}}
放在maketitle之前都可以
這個指令會自動把圖放在正下方
如果要放左下角 可以在\includegraphics之前加個\flushleft
當然 \flushright就到右下角
如果要放兩個 一左一右
可以\flushleft \includegraphics[...]{...} \hfill \flushright
\includegraphics...

無法解決的問題:
通常把這行\titlegraphic指令插在\date之前
但是swp55總是會自動把它移到\maketitle之後
以致於圖會不見
所以目前只能在投影片確定好之好
要真正generate講稿的時候
用WinEdt 或是記事本
強制把那行指令移過去對的地方
然後再latex

2010年3月23日 星期二

boxing equations

作者: hantis (呢呢是豬) 看板: Hantis
標題: [隨寫] Note: boxing equations
時間: Tue Mar 23 12:11:12 2010


   With amsmath package, there is one simple command to box a
   displayed equation: \boxed. Here is an example:

   \begin{equation} % equation, align, ... all work
   \boxed{f = ma}
   \end{equation}

   The above will give a boxed equation like

     __________
    |                       |
    |     f = ma       |       (1)
    |__________|

   However, whenever multiple lines are involved, this does not work.
   The empheq package is helpful here. This package is compatible with
   many commonly used packages such as amsmath and fancybox.

   Simplest usage is like

   \begin{empheq}[box=\fbox]{align}
   f & = ma \\
   p & = mv
   \end{empheq}

   These will give something like
    _______
   |                 |
   |   f = ma   |     (1)
   |   p = mv  |     (2)
   |_______|

   There are other types of boxes that can be called within the help
   of fancybox package. They are doublebox, ovalbox, and shadowbox.
   The last one may cause problem and needs some advanced modification.
   For the other two, one can just, for example,

   \begin{empheq}[box=\doublebox]{align}
   ....
   \end{empheq}

   ovalbox actually sucks. So ignore it.

2010年3月18日 星期四

\itemize in pspicture

作者: hantis (呢呢是豬) 看板: Hantis
標題: [隨寫] Note: \itemize in pspicture
時間: Thu Mar 18 11:44:17 2010


   Within pspicture environment, \itemize has to be wrapped within \parbox
   (or some others). For example,

   ...
   \pspicture(0,0)(8,8){
   ...
   \rput[l](1,2){\parbox{5cm}{\begin{itemize}%
   \item This is a test%
   \end{itemize}}%
   ...
   \endpspicture
   ...

2010年3月3日 星期三

eps file output by pstricks

作者: hantis (呢呢是豬) 看板: Hantis
標題: [隨寫] Note: eps file output by latex
時間: Wed Mar  3 11:02:38 2010


   pstricks and other extending packages provide
   great ps figures, but the output is tricky.

   The summary is:
   =========================
   \documentclass{article}
   \usepackage{pstricks}
   ...
   \pagestyle{empty}

   ...
   \fcolorbox{white}{white}{
   \pspicture(x1,y1)(x2,y2)
   ...
   \endpspicture
   }
   =========================
   (Better one figure one file.)
   compile commands:

   latex fig
   dvips fig ----> this allows a quick preview
   when done, then
   dvips fig -E -o fig.eps

   The file has to be (or not?) an eps file.

2010年2月18日 星期四

PostScript math commands

作者: hantis (呢呢是豬) 看板: Hantis
標題: [隨寫] Note: PostScript Math Commands
時間: Thu Feb 18 01:31:07 2010

http://www.ugrad.math.ubc.ca/Flat/math-ref.html

2009年12月16日 星期三

Word break

作者: hantis (呢呢是豬) 看板: Hantis
標題: [隨寫] Technical Notes: Word break
時間: Wed Dec 16 21:35:53 2009


   To break a word after a hyphen, a "discretionary" hyphen
   can be added by \-.
   Example: spin-independent => spin-indepen\-dent
   This "discretionary hyphen" will appear when it is necessary.

   Contrarily, ABC~DEFG avoids ABC DEFG being broken into two words.
   This will be especially helpful when using BibTex.
   For example, the author Massimiliano Di Ventra should be
   typed as Di~Ventra, Massimiliano, because Di Ventra is his
   full family name.