2013年5月6日 星期一

Switching between leqno and reqno

Using amsmath package, the equation numbering is by default set to right, i.e., reqno. It is possible to change to leqno by \documentclass[leqno,...]{article}, for example. However, if one desires to temporarily switch between the two a good solution can be found at

http://www.golatex.de/wechsel-zwischen-leqno-und-reqno-fleqn-uvm-t2488.html

For convenience, I paste Herbert's code here:

\makeatletter 
\def\Links{\tagsleft@true}\def\Rechts{\tagsleft@false} 
\makeatother 

Examples of use:

\begin{align}
y=f(x) 

\end{align} 

\Links 
\begin{align}
y=f(x) 

\end{align} 

\Rechts 
\begin{align}
y=f(x) 

\end{align} 

2013年3月22日 星期五

Printing "usable" postscript figure in windows 8

This note is to illustrate how to capture an image from a PDF and export as a postscript file in windows 8. The file has to be compatible with latex.

Previously in windows 7, this can be done by printing the selected image in Acrobat with the virtual printer "WMF2EPS Color PS L2". In Win8, there is also a virtual printer called "Microsoft PS Class Driver" that can print files or images as ps files. When viewing the output ps figures with ghostscript, they look pretty fine. The only problem is, there is no bounding box. Without bounding box, we cannot use them directly in doing latex.

The solution I found is that Matlab can help. There is an exchange file on the "File Exchange - MATLAB Central" called "export_fig" by Oliver Woodford. The file can be freely downloaded here. This mini-program outputs figure files in good qualities and may sometimes be needed, in addition to Matlab's built-in command "print". This export_fig can also do pdf2eps, but before having this function work, one has to download necessary files related with xpdf.

Anyway, when this function (pdf2eps) is activated, the following is then the simple procedure of how a captured image in a PDF file can be transformed to an EPS file that is compatible with LaTeX:

1. open the pdf file and select the desired image

2. right-click to print the selected image

3. choose the adobe acrobat virtual printer to output the image in the pdf format (ex.: image.pdf)

4. open matlab and use the pdf2eps command to transform the pdf file into an eps file; then it's done

An example is shown below to summarize the procedure:

Note:
1. In the last view, the dashed box of the eps file shown in ghostview is the bounding box, which is very important when doing latex.
2. Sometimes the boundary of the captured image in the pdf format is not satisfactory. This can be improved by cropping the file in the Adobe Acrobat.

2012年9月5日 星期三

newtheorem

要自訂新的 theorem 環境
可以用 amsthm 這個 package
非常方便
例如
\newtheorem{mynote}{Note}[chapter]
{mynote} 是新環境的名字,於是往後可以用 \begin{mynote}...\end{mynote}
{Note} 是這個新環境的標題
[chapter] 是跟編號有關
這個例子用在書的話,例如
\begin{mynote}
This is important.
\end{mynote}
大概會產生(假如是在第二章裡第一次使用)
Note 2.1.  This is important.

此外,這裡的 {mynote} 會出現在 swp 的下拉選單裡
而 {Note} 則是在 swp 的環境標題

細節的部分
說明檔已經很清楚
但是 \newtheoremstyle 的最後一個參數沒有說得很清楚
而且其實很簡單

按照說明檔:

\newtheoremstyle{note}% <name>
{3pt}% <Space above>
{3pt}% <Space below>
{}% <Body font>
{}% <Indent amount>
{\itshape}% <Theorem head font>
{:}% <Punctuation after theorem head>
{.5em}% <Space after theorem head>
{}% <Theorem head spec (can be left empty, meaning `normal')>
每個參數都算清楚
就只有最後一個參數沒說清楚
而這裡: http://users.stat.umn.edu/~geyer/amslatex.html
對最後這個 theorem head spec 有清楚的說明
(假如這個連結還在的話)

設定好這個新的 theoremstyle 之後
如果
\theoremstyle{note}
\newtheorem{mynote}{Note}[chapter]
則會把這個名叫 note 的新的 theoremstyle 套用到 mynote 這個新的 theorem 環境上
而按照上面這個 style
排出來的結果也差不多是 Note 2.1:  This is important.
就只是"Note"是斜體,還有2.1後面變冒號而已

舉個實際的例子:

\newtheoremstyle{ref}
{3pt}
{3pt}
{}
{}
{}
{}
{.5em}
{\Pointinghand\enspace [\thmnumber{#2}]}
\theoremstyle{ref}
\newtheorem{reading}{Further Reading}[chapter]

這個例子是用來當 further reading 的環境
安排在每一章之後
使得可以得到類似
-> [2.1] M. Johnson, Some Journal 99, 1234 (1995).
-> [2.2] S. Body, Some Journal 88, 4321 (1992).
的結果

新環境格式的最後一個參數我們用了{\Pointinghand\enspace [\thmnumber{#2}]}
\Pointinghand 其實是一隻手,這裡用 -> 代表,這個要\usepackage{marvosym}才行
\enspace 是插入一個小空格
\thmnumber{#2} 是編號 而我們外面用 [ ] 包起來
排出來也就照列

如果我們把這個最後一個參數留白{}
其效果等於是
{\thmname{#1}\thmnumber{ #2}}
注意到\thmnumber{ #2}裡面#2前面有個空格
而\thmname{#1}在這個例子就是Further Reading

這個實例裡
雖然我用了\newtheorem{reading}{Further Reading}[chapter]
而在設定 newtheoremstyle 時其實沒有用到\thmname{#1}
所以跟\newtheorem{reading}{}[chapter]效果其實一樣
然而差別是,前面已經提過
這個環境標題會在 swp 顯示
所以雖然不影響排版
但是在 swp 編輯的時候
看起來會比較舒服

2012年6月18日 星期一

老婆,生日快樂!

2011小泥生日卡(原尺寸在這
今天是一年一度小泥的生日,就破例叫個「老婆」吧!雖然我自己不喜歡過生日,但是慶祝小泥的生日到是挺樂意的,只是我也不會準備什麼禮物,我就只會做卡片,還有請吃大餐。蒐集一年來的生活照片製作成生日卡片,也只是去年開始有的慣例(希望以後真的能維持成「慣例」),只是相較於去年的卡片,過去這一年來累積的照片數量實在太驚人了,也於是光是挑選的過程就花了很多精力。


去年卡片的照片說明還不算太長,而今年的卡片要寫照片說明可能就太累人了,只能大致的寫點記錄。用地點分類的話,大部分是在 Regensburg 鎮上或家裡,然後環德旅行的照片雖然沒有每個城市都放,但還是占了很大部分,有 Bonn, Bremen, Rostock, Potsdam, Berlin, Dresden, Koenigstein, Wuerzburg。哥、嫂來訪時的照片也放了一點,有 Nuernberg, Muenchen, 王傑來訪的照片也是放 Nuernberg。十一月左右小泥安排的捷克之旅放的照片有 Praha, Karlovy Vary, Pilsen,然後就差不多耶誕節、跨年,回台灣過年的照片當然放了兩家人的合照,所以有岡山跟沙鹿。過完年回德國之後,天寒地凍時去了一趟 Lindau,也是很特別的回憶。復活節去西班牙找王傑玩,放的照片有 Santiago Bernabeu (Madrid) 跟 Sergovia,還有後來去 Barcelona 的照片不可能不放。西班牙之後去 Brussels 開會,雖然沒有感覺很有什麼,但還是放了一張作紀念。放到這裡已經很塞了,所以後來五月份星芸、王傑來訪的照片就沒放了,還有六月去的 Delft,可惜小泥最後沒同行,少了這個挺特別的荷蘭城市。


2012小泥生日卡(原尺寸在這
看起來好像去了很多地方,但其實我們夫妻倆肯定不是跑過最多地方的。只是能有這些機會去玩的話,當下不僅要好好認真的玩,去了解每個城市的背景、去感受每個地方的特色,適當的拍攝一些值得珍藏的照片,然後定期的把照片整理,就能讓回憶更加的生動而美麗。沒有人能有這麼多時間老是在整理這些吧,包含我也是。但是一年一度的小豬泥生日,看來是個很好的理由強迫整理。


除了值得回憶的風景、合照,其實最珍貴的是一些意外照到的怪泥樣,因為這才是最真實的小豬泥。無奈珍貴的怪泥照越來越難照到了,小泥最可愛的就是她怪裡怪氣的樣子,還有她變化多端的表情,然而這些都是小泥不可能擺在那裡任由我照的畫面。有鑑於這次的怪泥照太少,接下來這個年度我得更加努力捕捉怪泥畫面才行。

這次的卡片印成了 20cm x 30cm 的尺寸,有點算是意外,但是效果極好,只是有點不確定將來收藏會不會很困擾。但總之今天印了出來,跟在銀幕上看的感覺又更不一樣了。小泥,這是我為妳做的生日卡片,喜歡嗎?老婆,生日快樂!

2012年5月23日 星期三

用 latex 繪製中華民國國旗


中華民國國旗
這是前陣子心血來潮時寫的
規格按照中華民國國徽國旗法
成品預覽如右圖

以下是簡短簡易的 latex code
任何版友皆可享用
這裡有 eps 圖檔的成品

\documentclass{article}
\usepackage{pst-node}
\pagestyle{empty}

\begin{document}
\fcolorbox{white}{white}{%
\pspicture(-6,-4)(6,4)%
\psset{linewidth=1pt,unit=0.1cm}%
%%%%% 滿地紅
\psline*[linecolor=red](-60,-40)(60,-40)(60,40)(-60,40)%

\rput(-30,20){
%%%%% 青天
\psline*[linecolor=blue](-30,-20)(30,-20)(30,20)(-30,20)
%%%%% 白日
\psline*[linecolor=white]%
(15;0)(15;150)(15;300)(15;450)(15;600)(15;750)%
(15;900)(15;1050)(15;1200)(15;1350)(15;1500)(15;1650)(15;1800)%
%%%%% 藍圈
\pscircle*[linecolor=blue](0,0){8.5}
\pscircle*[linecolor=white](0,0){7.5}
}

\endpspicture
}
\end{document}

2012年4月30日 星期一

Creating chances is just not enough

To some extent, football games are quite similar to our lives. Creating chances is surely what we should keep on doing, but sometimes creating chances is just not enough. Instead, it's all about how many chances you can grab among the chances you've created.

FC Barcelona's recent defeat at home twice within one week by Real Madrid and by Chelsea was surely painful not only to themselves but also to the countless supporters from all over the world like me. Cesc Fabregas said after the Champion's league game against Chelsea that they were "loyal to their style", which was surely true and inspiring. However, the vital reason of their defeat was unfortunately too many chances they missed. Pressure was certainly also the reason that influenced their performance, since a 1-0 defeat at Stanford Bridge of Chelsea's home game had implied no room for the FCB to lose any goal at Camp Nou.

Fortunately, the FCB immediately rebounded back to their original level yesterday during the la liga away-match against Roya Vallecano with a final score of 0-7. Teamwork, skills, concentration, and amazingly wide eyesight, though may not be enough to win a match in games like Champion's league semi-final against Chelsea, are the most important and attractive ingredients of football, as I always believe.

某種程度來說,足球比賽就像人生一樣。創造機會肯定是我們必須不斷努力的,然而有時候光會創造機會是不夠的,重點是你能在創造出來的機會當中把握住多少。

巴塞隆納最近在一週內,連續兩次在自家的挫敗,一次對皇馬,一次對切爾西,肯定不光對他們自己也對全世界各地像我一樣的球迷是個沉重的打擊。週二對切爾西進軍本賽季歐冠決賽之路受挫後,法布雷加斯隔天表示「他們衷於他們的風格」。這是事實,也很鼓舞人心。然而無可否認的,他們遭受挫敗的關鍵原因,是錯過太多的機會。壓力肯定也是影響他們表現的原因,因為此前在切爾西主場已經吃下的1-0敗仗,說明了在自家第二輪的比賽被進任何一個球都會帶來極大的麻煩。

幸運的是,經過幾天放鬆與釋懷回到西甲賽場的巴塞隆納,昨天在客場對陣 Roya Vallecano 交出了大比分七比零的勝仗。團隊合作、技巧、專注力、還有驚人的視野等,也許有時候不見得足夠能贏下一場像歐冠四強對切爾西那樣的關鍵大賽,是足球最迷人也是最重要的成分,至少我一直都這麼認為,也會一直這麼相信下去。