Pygsl 的基本使用方法

这几天因为要用 python 处理一些有关矩阵的运算,NumPy 和 SciPy 都很合适。不过,因为我在 C 程序中比较中意 gsl,看到 pythons 有 gsl 的绑定—— pygsl。就尝试了一下。

Posted by LiYanrui Oct 31, 2008 05:48:29 PM


We need a perfect solution of Chinese support in TeX

These days I have tried to understand a few segments of source code about Chinese support in ConTeXt MkIV, because, with my own efforts, I want to solve the problem of Chinese puncuations appeared on the right side of pages which often affect the aesthetic feel of typesetting. I noticed that there two lines of code that look like unnecessary and I hide them with comment sign. After regenerating ConTeXt formats, I recompiled those documents that I have already finished including those in CTXnotes project. I found all is ok! Now Chinese puncuations never appear on the right side and the layout looks very tidy.

Posted by LiYanrui Oct 21, 2008 04:32:49 PM


被迫清心寡欲地使用中文字体

最近,ConTeXt MkIV 的混合字体机制出现了一个以前出现过的问题,即:在不同的 typescript 环境中(比如 Serif 和 Mono),如果向同一款中文字体的相同编码区域注入两种不同的西文字体,那么只有首次注入的西文字体才是有效的。That is to say, 只能是一款中文字体与一款英文字体进行混合。

Posted by LiYanrui Oct 19, 2008 05:42:37 PM


压缩标点之间的间距

昨天,耐心地阅读了 MkIV 的 font-otf.lua 最后那一部分处理中文的代码,终于看出了一点门道,并向其中添加了一小段代码用于压缩两个紧挨着的中文标点的间距。另外,font-otf.lua 也未对中文引号进行标点压缩,这个问题我也通过 hack 的方式解决了。

Posted by LiYanrui Oct 15, 2008 07:54:12 PM


今天终于解决了机器不能重启的问题

貌似从 kernel 2.6.24 伊始,我的 dell precision 490 在 reboot 的最后阶段便挂在那儿不动了,只好摁上 6 秒电源开关将机器关掉,然后再打开。今天,想再侥幸碰碰 kernel 2.6.27 的运气,结果问题依然如故。galeki 跟我说了一个内核的选项可能跟我这个问题有关,我尝试了一下,不解决问题。最后,我怒了,直接 google 了一下 “linux kernel dell 490 reboot”,结果我就看到了一份关于 f9 的 dell precision 490 的重启问题的帖子,尝试向内核传递 reboot=b 参数,终于解决了这个我已经容忍了许久的问题。

reboot=b 参数的意思似乎是让主板 BIOS 系统来接管机器的重启要求。

Posted by LiYanrui Oct 14, 2008 06:14:11 AM


首字下沉

Taco 从 LaTeX 的 lettrine.sty 宏包中 port 过来一个 t-lettrine,使得 ConTeXt 可以很方便地处理首字下沉问题。

\usetypescriptfile[type-gyr]
\usetypescript[palatino][qx]
\setupbodyfont[11pt,palatino]

\usemodule[lettrine]

\setuplettrine[Nindent=0pt]

\starttext

\lettrine{M}{an} was last to come but the first to use his brain for the purpose of conquering the forces of nature. That is the reason why we are going to study him, rather than cats or dogs or horses or any of the other animals, who, all in their own way, have a very interesting historical development behind them.

\stoptext

Posted by LiYanrui Oct 09, 2008 02:04:37 PM


页眉与页脚

若采用 Van de Graaf 版式,那么页面的外部留白较宽,页眉和页脚如果还是像传统那般分别设置在版心的正上和正下方,版面会显得过于紧张。应当将页眉和页脚向外侧都延伸过去一些才好,就像下面的这种样式:

偶数页的左侧页眉显示当前的章标题,奇数页的右侧页眉显示当前的小节标题。为了与页眉呼应一下,我将页码置于页脚的外侧。

下面是 ConTeXt 实现:

\def\Offset{\hbox to -1.6cm{}}

\def\CurrentChapter{%
  \tinyframed{第 \headnumber[chapter] 章}%
  \hbox to 1em{}%
  \tightframed{\getmarking[chapter]}%
}

\def\CurrentSection{%
  \tinyframed{\headnumber[section]}%
  \hbox to 1em{}%
  \tightframed{\getmarking[section]}%
}

\setupheadertexts
  [text][]
  [{\CurrentSection\Offset}]
  [{\Offset\CurrentChapter}][]

\setupfootertexts
  [text][]
  [\pagenumber\Offset]
  [\Offset\pagenumber][]

\setupfooter[style=\tfx]
\setupheader[style=\tfx]

\Offset 的具体大小,这个要根据具体的情况来定。比如,如果在边注区域显示一些文字、图形,为了保持版面协调,可以将 \Offset 的值再取大一些。

一开始,我不知道盒子是可以负向伸缩的。因为想到 CSS 有这个功能,便顺手试验了一下,不想居然真的可以。

Posted by LiYanrui Oct 08, 2008 09:49:31 PM


Van de Graaf 版式设计规则

读了 Wang Yue 的那篇“写一篇关于排版理论具体实践的文档来抛砖引玉”,对其中所提到的 J.A. van de Graaf 定义的的经典版式比较感兴趣。今天,略略学习了一下,并将它应用到了 “ConTeXt 学习笔记, Using MkIV”的版式定义中。

Posted by LiYanrui Oct 05, 2008 10:50:49 PM