Skip to main content

终于装好了中文LaTeX

很多作业要用LaTeX排版了,Linux下安装就是方便,TeX,LaTeX,teTeX,都是轻松安装,使用也不错,一个pdflatex命令就全搞定了,然而现在需要中文了,就不那么方便了。
Windows下可以去http://www.ctex.org下ctex套装,虽然有几百兆,可我用迅雷只花了3分种就下来了。安装很慢,用起来还可以,只是没试中文的情况,应该不用再配置了吧。
但是Linux下就麻烦很多了,唉,ctex为什么不开发个Linux版呢,害我花了好几个小时才弄好

我查到了主流解决方案有两个,UCS和CJK,一开始我用aptitude在源里找,都找到也都装了,但是在网上查安装方法却发现还要自己装字体。

USC在这里有介绍http://bbs.sayya.org/~edt1023/tex/ipeucs/node4.html,但是需要个cyberbit字体,我这里是烂教育网,没法下,最后只得放弃

然后就是CJK了,开始在apt源里发现了arphic字体,但是编译tex时总报错,只得作罢。
后来查了N多资料,有不少都十分麻烦,但是发现了这个:http://www.cublog.cn/u/29820/showart_236501.html,文中提到了个gbkfonts,可以在http://learn.tsinghua.edu.cn/homepage/2001315450/src/gbkfonts-linux-0.3.tar.gz下载,虽然我这里不能编译(它竟然是用cc编译的),但是压缩里有编译好的程序,需要用的是gbkfonts和一个叫appendconf的脚本。
现在要从windows里拷如下几个字体文件:simfang.ttf,simkai.ttf,simhei.ttf,simsun.ttc,放到~/fonts里,再把gbkfonts,appendconf也拷过来,运行
./gbkfonts simfang.ttf fang
./gbkfonts simkai.ttf kaif
./gbkfonts.simhei.ttf hei
./gbkfonts simsun.ttc song
(其中最后一个参数表示在tex中使用的字体名)
然后直接运行gbkfonts,会出介绍,最后让你把dvips, tex, dvipdfm,fonts几个目录拷到/usr/share/texmf里
再运行appendconf就好了,参数是/usr/share/texmf
(因为我这里tex都是用sudo aptitude装的,所以都装到/usr/lib /usr/share...去了,而不是/usr/local/...)

生成pdf时仍有问题,需要个dvipdfmx,用apt装一下吧。

这就算装完了,试试看

\documentclass{article}
\usepackage{CJK}
\title{Font Test}
\author{WangLu}
\begin{document}
\maketitle
\begin{CJK}{GBK}{song}
宋体测试\\
\end{CJK}
\begin{CJK}{GBK}{kai}
楷体测试\\
\end{CJK}
\begin{CJK}{GBK}{hei}
黑体测试\\
\end{CJK}
\begin{CJK}{GBK}{fang}
仿宋体测试\\
\end{CJK}
\end{document}


存为test.tex
然后
latex test
dvipdfmx test.dvi
查看 test.pdf。。。嗯,不错

Comments

Tate TIAN said…
我下回在linux下用的时候过来参考一下

Popular posts from this blog

Determine Perspective Lines With Off-page Vanishing Point

In perspective drawing, a vanishing point represents a group of parallel lines, in other words, a direction. For any point on the paper, if we want a line towards the same direction (in the 3d space), we simply draw a line through it and the vanishing point. But sometimes the vanishing point is too far away, such that it is outside the paper/canvas. In this example, we have a point P and two perspective lines L1 and L2. The vanishing point VP is naturally the intersection of L1 and L2. The task is to draw a line through P and VP, without having VP on the paper. I am aware of a few traditional solutions: 1. Use extra pieces of paper such that we can extend L1 and L2 until we see VP. 2. Draw everything in a smaller scale, such that we can see both P and VP on the paper. Draw the line and scale everything back. 3. Draw a perspective grid using the Brewer Method. #1 and #2 might be quite practical. #3 may not guarantee a solution, unless we can measure distances/p...

Chasing an IO Phantom

My home server has been weird since months ago, it just becomes unresponsive occassionally. It is annoying but it happens only rarely, so normally I'd just wait or reboot it. But weeks ago I decided to get to the bottom of it. What's Wrong My system set up is: Root: SSD, LUKS + LVM + Ext4 Data: HDD, LUKS + ZFS 16GB RAM + 1GB swap Rootless dockerd The system may become unresponsive, when the IO on HDD  is persistantly high for a while. Also: Often kswapd0 has high CPU High IO on root fs (SSD) From dockerd and some containers RAM usage is high, swap usage is low It is very strange that IO on HDD can affect SSD. Note that when this happens, even stopping the IO on HDD does not always help. Usually restarting dockerd does not help, but rebooting helps. Investigation: Swap An obvious potential root cause is the swap. High CPU on kswapd0 usually means the free memory is low and the kernel is busy exchanging data between disk and swap. However, I tried the following steps, none of the...

Moving Items Along Bezier Curves with CSS Animation (Part 2: Time Warp)

This is a follow-up of my earlier article.  I realized that there is another way of achieving the same effect. This article has lots of nice examples and explanations, the basic idea is to make very simple @keyframe rules, usually just a linear movement, then use timing function to distort the time, such that the motion path becomes the desired curve. I'd like to call it the "time warp" hack. Demo See the Pen Interactive cubic Bezier curve + CSS animation by Lu Wang ( @coolwanglu ) on CodePen . How does it work? Recall that a cubic Bezier curve is defined by this formula : \[B(t) = (1-t)^3P_0+3(1-t)^2tP_1+3(1-t)t^2P_2+t^3P_3,\ 0 \le t \le 1.\] In the 2D case, \(B(t)\) has two coordinates, \(x(t)\) and \(y(t)\). Define \(x_i\) to the be x coordinate of \(P_i\), then we have: \[x(t) = (1-t)^3x_0+3(1-t)^2tx_1+3(1-t)t^2x_2+t^3x_3,\ 0 \le t \le 1.\] So, for our animated element, we want to make sure that the x coordiante (i.e. the "left" CSS property) is \(...