免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1725 | 回复: 0
打印 上一主题 下一主题

TeXLive中英文混排的间隔处理 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-26 20:22 |只看该作者 |倒序浏览
1. 采用CJKspace包,用的时候,首先把.emacs里面的适当位置添加如下内容
;; You should put the following in your .emacs file (additionally to the
;; common AUCTeX adaptations):
;;
;;   (autoload 'CJK-insert-space "cjkspace"
;;     "Insert tildes appropriately in CJK document." t)
;;    (defun my-LaTeX-mode-hook ()
;;     "Key definitions for LaTeX mode."
;;     (define-key LaTeX-mode-map " " 'CJK-insert-space)
;;     )
;;   (add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-hook)
;;; Code:
(provide 'cjkspace)
(defvar CJK-space "~")
(defvar CJK-space-after-space nil
  "*If non-nil, typing a space yields a space.  Typing two consecutive
spaces yields a tilde.  If nil the behaviour is reversed.")
(make-variable-buffer-local 'CJK-space-after-space)
;;;###autoload
(defun CJK-insert-space (arg)
  "Insert tilde characters instead of spaces for LaTeX CJK documents.
If `CJK-space-after-space' is non-nil, typing a space yields a space.
Typing two consecutive spaces yields a tilde.  If `CJK-space-after-space'
is nil, the behaviour is reversed.
With prefix argument, always inserts space characters."
  (interactive "*P")
  (if arg
      (self-insert-command (prefix-numeric-value arg))
    (TeX-update-style)
    (if CJK-space-after-space
        (insert (cond ((bobp)
                       ?\ )
                      ((not (= (preceding-char) ?\ ))
                       ?\ )
                      ((and (> (point) 2)
                          (save-excursion
                             (forward-char -2)
                             (looking-at (concat "[" CJK-space
                                                 (regexp-quote TeX-esc) "]"))))
                           ?\ )
                      (t
                       (delete-backward-char 1)
                       CJK-space)))
      (insert (cond ((bobp)
                     ?\ )
                    ((= (preceding-char) (string-to-char TeX-esc))
                     ?\ )
                    ((= (preceding-char) ?\ )
                     ?\ )
                    ((and (> (point) 2)
                        (save-excursion
                           (forward-char -2)
                           (looking-at (concat (regexp-quote TeX-esc)
                                               CJK-space))))
                         CJK-space)
                    ((= (preceding-char) (string-to-char CJK-space))
                     (delete-backward-char 1)
                     ?\ )
                    (t
                     CJK-space))))))
;;; EOF
2.   用法:
     实例:
\documentclass[11pt]{article}
\usepackage{CJK}\usepackage{CJKspace}
\begin{document}
\parindent 2em
\begin{CJK*}{UTF8}{gbsn}
这是 English 中文 \textit{Chinese} 中文 {\itshape Italic} 数学 $x=y$
  混排 \verb+anything+
这是English中文\textit{Chinese}中文{\itshape Italic}数学$x=y$
混排\verb+anything+
这是~English~中文~\textit{Chinese}~中文~{\itshape Italic}~数学~$x=y$~混排~\verb+anything+
  混排 \verb+anything+ 保持 \texttt{spaces} 空格 \LaTeX\ 间隔
  \mbox{boxes} 盒子 \hbox{hbox} 中文 123456 数字.
\end{CJK*}
\end{document}
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/74418/showart_2131646.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP