用Git+Sphinx記筆記?

來源:互聯網
上載者:User

接前面 TeX、LaTeX、TeXLive
小結,練習使用Sphinx寫點東西:

效果

圖1:


圖2:


git

Google code 提供Git

  • http://code.google.com/p/debao-qt-blogs/

只是不清楚什麼原因,無論 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 了。

  • https://gitorious.org/hexamples/blogs

sphinx

在TeX、LaTeX、TeXLive
小結一文中,是直接修改Sphinx的latex產生器來支援中文的,不過稍後發現,設定項目的設定檔就可以實現了:

  • conf.py

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.