接前面 TeX、LaTeX、TeXLive
小結,練習使用Sphinx寫點東西:
效果
圖1:
圖2:
git
Google code 提供Git
只是不清楚什麼原因,無論 push 還是 pull 總是失敗。(偉大的牆在發揮作用?)
* About to connect() to code.google.com port 443 (#0)* Trying 72.14.203.102... * Connection timed out* Failed connect to code.google.com:443; Connection timed out* Closing connection #0* About to connect() to code.google.com port 443 (#0)* Trying 72.14.203.102... * Connection reset by peer* Failed connect to code.google.com:443; Connection reset by peer* Closing connection #0error: Failed connect to code.google.com:443; Connection reset by peer while accessing https://code.google.com/p/debao-qt-blogs/info/refs
那就使用 gitorious 了。
sphinx
在TeX、LaTeX、TeXLive
小結一文中,是直接修改Sphinx的latex產生器來支援中文的,不過稍後發現,設定項目的設定檔就可以實現了:
latex_elements = { 'babel':'', 'fontpkg':'', 'inputenc':'', 'fontenc':'', 'utf8extra':''}latex_docclass = { 'howto':'ctexart', 'manual':'ctexrep'}
只需要添加這兩項即可。
儘管如此,Sphinx的latex產生器還是很不成熟,在當前穩定版Sphinx 1.0.8 尚不支援表格的rowspan和colspan。源碼倉庫中的Sphinx 1.1 開始支援表格的這兩個屬性,不過rowspan有bug(無法正常工作)。
簡單改動一下,湊活一下:
birkenfeld-sphinx-0dc8c4da3ef5
--- a/latex.py+++ b/latex.py@@ -730,19 +730,29 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_row(self, node): self.table.col = 0 def depart_row(self, node):+ for col in range(self.table.col, self.table.colcount):+ self.body.append(' & ') if self.previous_spanning_row == 1:- self.previous_spanning_row = 0+ #self.previous_spanning_row = 0 self.body.append('\\\\\n') else: self.body.append('\\\\\\hline\n') self.table.rowcount += 1 def visit_entry(self, node):- if self.remember_multirow.get(0, 0) > 1:- self.body.append(' & ')+ print "visit_entry:", self.table.rowcount, self.table.col, self.table.c+ for col in range(self.table.col, self.table.colcount):+ if self.remember_multirow.get(col, 0) > 1:+ self.remember_multirow[col] -= 1+ if self.remember_multirow[col] == 1:+ self.previous_spanning_row = 0+ if self.table.col > 0:+ self.body.append(' & ')+ else:+ self.table.col = col+ break if self.table.col > 0: self.body.append(' & ')- self.table.col += 1 self.context.append('') if 'morerows' in node: self.body.append(' \multirow{')@@ -751,10 +761,11 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append('}{*}{') self.context.append('}') self.remember_multirow[self.table.col] = node.get('morerows') + 1+ self.previous_spanning_row = 1 if 'morecols' in node: self.body.append(' \multicolumn{') self.body.append(str(node.get('morecols') + 1))- if self.table.col == 1:+ if self.table.col == 0: self.body.append('}{|l|}{') else: self.body.append('}{l|}{')@@ -762,9 +773,7 @@ class LaTeXTranslator(nodes.NodeVisitor): if isinstance(node.parent.parent, nodes.thead): self.body.append('\\textbf{') self.context.append('}')- if self.remember_multirow.get(self.table.col + 1, 0) > 1:- self.remember_multirow[self.table.col + 1] -= 1- self.context.append(' & ')+ self.table.col += 1 def depart_entry(self, node): self.body.append(self.context.pop()) # header