LaTeX技巧009:中國象棋的LaTeX排版

Latex能夠排版容易排版中國象棋, 圍棋, 國際象棋棋譜和曲譜, 詳情請見.php

http://bbs.chinatex.org/forum.php?mod=viewthread&tid=4987&extra=page=1html

這裏以中國象棋棋譜爲例:ide

中國象棋所需宏包:cchess(Chinese chess)\usepackage{cchess}spa

\normalboard 畫出棋盤,而後用 position 環境置子,code

縱線自左向右爲:a, b, . . . , i,橫線由下而上爲:1, 2, . . . , 10orm

置子命令爲htm

\piece {x}{y}{?}blog

x, y 爲橫縱座標,如前所述,? 爲棋子,符 號:ip

R車    N馬    B象    G士    K將    G士    B象    N馬    R車
                                                                           
         C砲                                                C砲        
P卒             P卒             P卒             P卒             P卒
                                                                           
       楚河                                             漢界           
                                                                            
p兵             p兵             p兵             p兵             p兵
         c炮                                                 c炮        
                                                                           
r車     n馬    b相    g仕    k 帥    g 仕   b相     n馬    r車
 

基本上紅子就是黑子的小寫字母版本get

利用 \textpiece 命令能夠排出具體的着法,好比:

\textpiece{c}八進四

命令能夠達到 「炮八進四」 的效果

下面來看一個具體的源文件mychess.tex

 1 \documentclass{article}
 2 \usepackage{cchess}
 3 \begin{document}
 4 \normalboard
 5 \begin{position}
 6 \piece{a}{1}{r} \piece{i}{1}{r}
 7 \piece{b}{1}{n} \piece{h}{1}{n}
 8 \piece{c}{1}{b} \piece{g}{1}{b}
 9 \piece{d}{1}{g} \piece{f}{1}{g}
10 \piece{e}{5}{c} \piece{e}{7}{c}
11 \piece{a}{4}{p} \piece{c}{4}{p}
12 \piece{e}{4}{p} \piece{g}{4}{p}
13 \piece{i}{4}{p} \piece{e}{1}{k}
14 \piece{a}{9}{R} \piece{i}{10}{R}
15 \piece{a}{8}{N} \piece{g}{8}{N}
16 \piece{c}{10}{B} \piece{g}{10}{B}
17 \piece{d}{10}{G} \piece{f}{10}{G}
18 \piece{b}{8}{C} \piece{h}{8}{C}
19 \piece{a}{7}{P} \piece{c}{7}{P}
20 \piece{g}{7}{P}
21 \piece{i}{7}{P} \piece{e}{10}{K}
22 \end{position}
23 \end{document}
View Code

注意一下編譯的順序: latex--- >dvips--- >ps2pdf

效果圖:

必定要按這個步驟來編譯, 否則獲得的效果很差.

若是你的latex尚未chess宏包, (點擊這 裏).

或到:

http://www.ctan.org/tex-archive/macros/latex/contrib/cchess/

下載便可。

選自:http://quantumfield.spaces.live.com/blog/cns!f433639184bc15ec!322.entry

另外,還有xq.sty宏包,關於LaTeX排版象棋的詳細討論還能夠查看CTeX論壇

相關文章
相關標籤/搜索