[Home] [Linguistics:] [Fieldwork:] [Databases:] [Linux:] [Debian:] [Windows:] [Miscellaneous]

Emacs and LaTeX

145x140(6322bytes) This page mainly shows settings for Emacs and LaTeX on Linux. To see settings for Emacs and LaTeX on Windows. Click here.

LaTeX
pLaTeX
Inverse search
Forward search
Emacs
Emacs font size
Font-lock mode
dot.emacs
sharing a diary file between emacs on linux and meadow on Windows under the Japanese language environment on dual-boot machines
migemo
Word-count-mode
Mew
YaTeX
Html-helper-mode
Fonthtml (key bindings for font colour to work with html-helper-mode module.)
Browse-kill-ring
RefTeX
Typesetting with a master file
BiBTeX
bib.file.in.one.directory
JabReF

LaTeX

Links

pLaTeX

Installation

# apt-get install ptex-bin tipa yatex mew html-helper-mode nkf
# apt-get install dvipsk-ja xdvik-ja xpdf-reader xpdf-japanese okumura-clsfiles gs gs-cjk-resource

# apt-get install vfdata-morisawa5
# jisftconfig add [Do this after you did # vfdata-morisawa5 to enable Japanese on dvips.]

# apt-get install dvipdfmx
# apt-get install cmap-adobe-cns1 cmap-adobe-gb1 cmap-adobe-japan1 cmap-adobe-japan2
# emacs /etc/texmf/texmf.d/50dvipdfmx.cnf [chage the file as follows:]
# update-texmf

Setting up your own texmf directory:

create a texmf directory for your LaTeX packages in your home directory:

$ cd /home/your-directory
$ mkdir texmf

Since I back up my texmf directory to a CD-ROM, I do the followings:

$ cd /etc
$ cat fstab [check dev for your cdrom and mount point.] # mount /dev/cdrom /cdrom
# cd /cdrom/localtexmf
# cp -R tex /home/your-directory/texmf/
# mktexlsr [reconfiguring LaTeX.]

Customizing

To change default settings such as fonts size etc of xdvi, See here.

Times.sty problem to view files on xdvi and kdvi.

times.sty does not work for /sc and /it.

Inverse search

You need to put srcltx.sty (srctex.sty if you use plain TeX) to your latex package directory. You also need to add the line \usepackge[active]{srcltx} to the preamble of your LaTeX files. Don't forget to reconfigure your TeX by doing $ mktexlsr.

Forward search

Forward search in xdvik

Usage:

C+c t j

Then type in minibuffer like:

-sourceposition "1000 filename" [to display line 1000 of the file, filename.dvi]

Forward search in kdvi

# mkdir ~/emacs-scripts

Put kdvi-search.el by Stefan Kebekus to this directory.

Add the following lines to your .emacs file.

(add-to-list 'load-path (expand-file-name "/home/tatsuya/emacs-scripts/"))
(require 'kdvi-search)
(add-hook 'LaTeX-mode-hook (lambda () (local-set-key "\C-x\C-j" 'kdvi-jump-to-line)))
(add-hook 'tex-mode-hook (lambda () (local-set-key "\C-x\C-j"'kdvi-jump-to-line)))

Click with the middle bottom of the mouse on the kdvi screen, then a new instance will open to bring you to the tex file. C-x C-j doesn't work on my LaTeX.

Add the line below in the dot emacs file if you don't want a new instance open when doing forward searech in kdvi:

(server-start)

Emacs

Emacs font size

If you want to change font size on emacs on X11 on linux, set dot.Xresources file in your home directory like this (4.Oct.2006):

Emacs.Fontset-0: -*-fixed-medium-r-normal--14-*-*-*-*-*-fontset-14,\
korean-ksc5601:-*-mincho-medium-r-normal--16-*-*-*-*-*-ksc*-*,\
chinese-gb2312:-*-fang*-medium-r-normal--16-*-*-*-*-*-gb2312*-*
Emacs.Fontset-1: -*-fixed-medium-r-normal--12-*-*-*-*-*-fontset-12
Emacs.Fontset-2: -*-fixed-medium-r-normal--24-*-*-*-*-*-fontset-24
Emacs.Fontset-3: -*-fixed-medium-r-normal--16-*-*-*-*-*-fontset-16,\
korean-ksc5601:-*-mincho-medium-r-normal--16-*-*-*-*-*-ksc*-*,\
chinese-gb2312:-*-fang*-medium-r-normal--16-*-*-*-*-*-gb2312*-*
Emacs.Font:fontset-14

Font-lock mode

Settings for emacs22

Go to Options > Customize Emacs > Top-level Customization Group > faces > Font Lock > Font Lock Faces group.

My current colour settings are:

Settings for emacs21

To use your own colour for syntax-highlighting, put the following settings to dot emacs:

;; Fonts ---------------------
;; font-lock
(global-font-lock-mode 1)
;(setq global-font-lock-mode t) ; this command does not work on Meadow and I use the one above.

;; Speeding up loading files with use font-lock mode (only effective for emacs21)
(setq font-lock-support-mode 'jit-lock-mode)

The following settings for syntax-highlighting are to realise an image of 'chalk on blackboard' on the screen.

; +++ Syntax-highlighting for LaTeX mode +++ ;;
;; The followings are my own colour for syntax-highlighting.
;; The lines added by 03/01/04

(add-hook 'font-lock-mode-hook '(lambda ()

;; comment
(set-face-foreground 'font-lock-comment-face "maroon1") ;firebrick1, orange red,indian red,maroon1,violetred3, maroon2, lightsalmon2
;; other candiates: darkred, firebrik1-4,violetred,
(set-face-background 'font-lock-comment-face nil)
(set-face-bold-p 'font-lock-comment-face nil)
(set-face-italic-p 'font-lock-comment-face nil)
(set-face-underline-p 'font-lock-comment-face nil)

;;string
(set-face-foreground 'font-lock-string-face "green") ; cyan3, dark cyan
(set-face-background 'font-lock-string-face nil)
(set-face-bold-p 'font-lock-string-face nil)
(set-face-italic-p 'font-lock-string-face nil)
(set-face-underline-p 'font-lock-string-face nil)

;; keyword
(set-face-foreground 'font-lock-keyword-face "lemonchiffon4")other candidates: lemonchiffon4, spring green,green yellow, forest green, lawn green, light cyan, green4, darkgreen, cyan, turquoise, chartreuse,
(set-face-background 'font-lock-keyword-face nil)
(set-face-bold-p 'font-lock-keyword-face nil)
(set-face-italic-p 'font-lock-keyword-face nil)
(set-face-underline-p 'font-lock-keyword-face nil)

;; builtin -> \XXX for LaTeX
(set-face-foreground 'font-lock-builtin-face "deepskyblue");; mediumspringgreen, magenta4
;; other candiates: mediumseagreen, aquamarine, olivedrab, deeppink, magenta, darkorange
(set-face-background 'font-lock-builtin-face nil)
(set-face-bold-p 'font-lock-builtin-face nil)
(set-face-italic-p 'font-lock-builtin-face nil)
(set-face-underline-p 'font-lock-builtin-face nil)

;; function-name
(set-face-foreground 'font-lock-function-name-face "sandybrown") ; other candidates: blueviolet,
(set-face-background 'font-lock-function-name-face nil)
(set-face-bold-p 'font-lock-function-name-face nil)
(set-face-italic-p 'font-lock-function-name-face nil)
(set-face-underline-p 'font-lock-function-name-face nil)

;; variable-name
(set-face-foreground 'font-lock-variable-name-face "deepskyblue") ;green,BlueViolet
(set-face-background 'font-lock-variable-name-face nil)
(set-face-bold-p 'font-lock-variable-name-face nil)
(set-face-italic-p 'font-lock-variable-name-face nil)
(set-face-underline-p 'font-lock-variable-name-face nil)

;;type
(set-face-foreground 'font-lock-type-face "lemonchiffon4") ; mediumspringgreen
(set-face-background 'font-lock-type-face nil)
(set-face-bold-p 'font-lock-type-face nil)
(set-face-italic-p 'font-lock-type-face nil)
(set-face-underline-p 'font-lock-type-face nil)

;; constant
(set-face-foreground 'font-lock-constant-face "indianred") ;; indianRed
(set-face-background 'font-lock-constant-face nil)
(set-face-bold-p 'font-lock-constant-face t)
(set-face-italic-p 'font-lock-constant-face nil)
(set-face-underline-p 'font-lock-constant-face nil)

;; warning
(set-face-foreground 'font-lock-warning-face "Red3")
(set-face-background 'font-lock-warning-face nil)
(set-face-bold-p 'font-lock-warning-face nil)
(set-face-italic-p 'font-lock-warning-face nil)
(set-face-underline-p 'font-lock-warning-face nil)
))
(provide 'faces-font-lock)

dot emacs

Here are my dot emacs files: resources and my current dot emacs file.

Click here to use anthy on emacs.
Click here to set up mew on emacs.

Howto share a diary file between emacs on linux and meadow on Windows under the Japanese language environment on dual-boot machines

# nkf -s < your-original-diary-file > diary [chage the character code of your diary file into Shift JIS ]
# mv diary /your-home-directory-of-meadow-on-windows-partition [move the diary file to a home directory of Meadow. The file system of the Windows partition should be in vfat.]
# ln -s /path-to-your-home-directory-of-meadow-on-windows-partition/diary /path-to-your-home-directory-on-linux/diary [link the diary file to a home directory of emacs on linux.]

Now you can share the diary file between meadow on Windows and emacs on Linux on the dual-boot machine.

migemo

You need to install ruby to use migemo.

# apt-get install migemo ruby

Add the path to migemo.el to .emacs. Word-count-mode
# mkdir ~/elisp [put word-count.el to this directory.]

Startup screen

(setq inhibit-startup-message nil) ;; skip the opening message.
(setq initial-scratch-message nil) ;; without scratchmessage.



Enable scroll with mouse

; normal scroll 5 line
; mouse2 + shift key: 1 line
; mouse2 + C half: page
(global-set-key [mouse-4] '(lambda () (interactive) (scroll-down 5)))
(global-set-key [mouse-5] '(lambda () (interactive) (scroll-up 5)))

; Shift (global-set-key [S-mouse-4] '(lambda () (interactive) (scroll-down 1)))
(global-set-key [S-mouse-5] '(lambda () (interactive) (scroll-up 1)))

; Control (global-set-key [C-mouse-5] '(lambda () (interactive) (scroll-up (/ (window-height) 2))))
(global-set-key [C-mouse-4] '(lambda () (interactive) (scroll-down (/ (window-height) 2))))


Auto-fill

(setq text-mode-hook ' turn-on-auto-fill)
(add-hook 'text-mode-hook
'(lambda ()
(progn (set-fill-column 60)
(turn-on-auto-fill))))


Removeing blank spaces after the end of each line

(defun trim-buffer ()
"Delete excess white space."
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "[ \t]+$" nil t)
(replace-match "" nil nil))
(goto-char (point-max))
(delete-blank-lines)
))
(add-hook 'write-file-hooks 'trim-buffer)



Replace yes/no+enter prompts with y/n prompts

(fset 'yes-or-no-p 'y-or-n-p)


How to change font size
M-x customize-face RET default RET
Follow the prompts, don't forget to save your changes.

ftp

accessing to ftp with emacs ange-ftp

Mew

Links
Install
Here is my current dot mew file.

Setting a dot mew file

loading Mew

(setq load-path (cons "/usr/local/share/emacs/site-lisp/mew/" load-path))
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
(setq mew-icon-directory "/root/mew-3.3/etc/")
;; change path to where your mew.img is.
;; You can start Mew as a root usr without setting the above path, but you
;; need to set the load path for mew.img like above for non-root users.
;; If you installed Mew by apt-get install, the path is '/usr/share/pixmaps/mew/'.
;; (setq mew-icon-directory "icon directory")

(if (boundp 'read-mail-command)
(setq read-mail-command 'mew))


;;; add D mark to doubled messages. (setq mew-scan-form-mark-delete t) Viewing URL from Mew by Mozzila

(setq browse-url-browser-function 'browse-url-netscape)
(autoload 'browse-url-at-mouse "browse-url"
"Ask a WWW browser to load a URL clicked with the mouse." t)
(add-hook 'mew-message-mode-hook
(function
(lambda()
(local-set-key [mouse-2] 'browse-url-at-mouse))))
;; using mozilla instad of netscape;;
(setq browse-url-netscape-program "mozilla")

To send ccs to someone everytime you send e-mails.

(setq mew-cc "your@e-mailaccount") [put this line to your dot emacs file.]

To keep copies of outgoing mails in 'send' directory in ~/Mail, add the following line to your dot emacs file.

(setq mew-fcc "+send")

Changing Mail directory
To change your Mail directory, use the followings:

(setq mew-conf-path "YOUR NEW DIRECTORY"
mew-mail-path "YOUR NEW DIRECTORY")


(setq text-mode-hook ' turn-on-auto-fill)
(add-hook 'text-mode-hook
'(lambda ()
(progn (set-fill-column 70)
(turn-on-auto-fill))))

You can M-q to shape your document.

Leaving messages on the servers
Note that the line should not be in the dot emacs file. If do so, pop accont settings in the dot.mew file conflict with it and Mew won't be able to reach the server.)

(setq mew-pop-delete nil)

Multiple-account settings
When changing from one to another account type i (retrieve mails from a pop account.) then type capital c and a mini buffer in which you can choose your accout will appear.

(setq mew-config-alist
'(("default"
("name" . "Edward Sapir")
("user" . "esapir")
("mail-domain" . "linguistgreat.ne.us")
("smtp-server" . "smtpv.sapir.ne.us")
("pop-server" . "pop.sapir.ne.us")
("pop-size" . 0)
("pop-auth" . pass)
("pop-user" . "esapir"))

("second"
("name" . "W von Humboldt")
("user" . "wvhumboldt")
("mail-domain" . "linguistgreat.ne.du")
("smtp-server" . "smtpv.humboldt.ne.du")
("pop-server" . "pop.humboldt.ne.du")
("pop-size" . 0)
("pop-auth" . pass)
("pop-user" . "wvfunbolt"))))


Read pdf files

# emacs /usr/share/emacs/site-lisp/mew/mew-unix.el

Organise incoming mails

YaTeX

Links:

Basic usages:

Setting a dot emacs file

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq auto-mode-alist
(cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
(setq load-path (cons (expand-file-name "d:/home.d/tatsuya.d/texmf/yatex1.72") load-path))
(load "yatex")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Note that if there are any spaces in the path YaTeX does not reach the destination.

Additional syntax hilighting for YaTeX

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq my-YaTeX-font-lock-keywords
'(("\\(\\\\\\(left\\|right\\)\\([][().|]\\|\\\\[{}]\\)\\)"
(0 font-lock-warning-face))
("\\(|\\|&\\|\\\\[{}]\\|\\\\\\\\\\)" (0 font-lock-warning-face))

("\\\\[a-zA-Z]*" (0 font-lock-builtin-face))
))
(add-hook 'yatex-mode-hook
'(lambda ()
(setq
YaTeX-font-lock-keywords
(append YaTeX-font-lock-keywords my-YaTeX-font-lock-keywords))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Html-helper-mode

Put html-helper-mode.el into /YOUR EMACS DIRECTORY/site-lisp
Add the following lines to dot emacs: Add the following lines if necessary:

Fonthtml

Fonthtml provides you with key bindings for font colours to work with html-helper-mode module.

Html-helper-mode does not have key bindings for font colour and I create the file, Fonthtml, for me to use. You are welcome to copy and modify the file for your own needs and if you could let me know your modifications to improve Fonthtml, that will be greatly appreciated.

Here is my fonthtml.el.

Add the following lines to .emacs:

Browse-kill-ring

Links:
Put browse-kill-ring.el to your site-lisp directory and add the following lines to your .emacs file.

(require 'browse-kill-ring)
(global-set-key "\M-y" 'browse-kill-ring


Add the following lines if necessary:

;; showing in one line.
(setq browse-kill-ring-display-style 'one-line)

;; kill buffer when quit
(setq browse-kill-ring-quit-action 'kill-and-delete-window)

;; highlight the current selection
(setq browse-kill-ring-highlight-current-entry t)

RefTeX

RefTeX: turn on RefTeX Mode for all LaTeX files (YaTeX settings)

(add-hook 'yatex-mode-hook '(lambda () (reftex-mode-t)))
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode


The setting above for YaTeX basically works but the following setting is better for the latest RefTeX mode.

  • Yutaka SHINDOH. BibTeX, BibTeX-mode, RefTeX-mode Howto


  • ((add-hook 'yatex-mode-hook
    '(lambda ()
    (reftex-mode 1)
    (define-key reftex-mode-map
    (concat YaTeX-prefix ">") 'YaTeX-comment-region)
    (define-key reftex-mode-map
    (concat YaTeX-prefix "<") 'YaTeX-uncomment-region)))


    Typesetting with a master file

    ***** master file (master.tex) looks like this ******

    \documentclass[12pt]{book}
    \begin{document}

    \include{chapter1}
    \include{chapter2}

    \bibliographystyle{apalike}
    \bibliography{bibling-jabref}
    \end{document}

    %%% Local Variables:
    %%% mode: yatex
    %%% TeX-master: t
    %%% End:

    ***************************************


    ********* input files look like this **********

    %#!latex master.tex

    input files need the four lines below in order to type set with yatex and also to generate bibliography at the end of the whole document.

    If you want to generate bibliography for your chapters which are included in the master file at the end of your whole document, you can do so only by typesetting the master file (not files for each chapter). So, if you are writing chapter 1 with chapter1.tex, you should go to master.tex and then type set this file.

    %%% Local Variables:
    %%% mode: platex
    %%% TeX-master: "master"
    %%% End:

    *****************************************

    BiBTeX

    bib file in one directory

    If you want to put *.bib file in one folder separetely. Add environmental variable like below (Windows XP).

    BIBINPUTS X:/X/Y/your-bib-file-directory


    If you use linux put the line below to .profile (ubuntu 10.04) or .bashrc (ubuntu 8.04).

    export BIBINPUTS "/X/Y/your-bib-file-directory"



    JabReF



    TOP