[OS X Emacs] guess-TeX-master problem

Hofert Jan Marius marius.hofert at math.ethz.ch
Thu Sep 15 04:45:48 EDT 2011


Dear all,

I installed of Aquamacs 2.3a on a MacBook Pro 10.6.8. I was hoping that the solution posted under the subject "Wiki code not working: Symbol's function definition is	void: guess-TeX-master" worked again, but it doesn't (and I don't know why). The goal is to get Aquamacs to compile an example.tex document which does not have a proper header but is simply a tex file included in a "master .tex file", call it master.tex. 

Following the previous posts, I have these entries in Preferences.el (just in case this has any influence on the problem, I included other commands too (only those that also affect latex mode; apart from that, I only have some R commands defined in Preferences.el)):

### Preferences.el ######################################

;; suggestions from the AUCTeX manual 
(require 'tex-site)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

;; turn on LaTeX Math mode by default
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

;; turn on auto fill in LaTeX
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)

;; setup for master file when working on projects with multiple .tex files 
(defun guess-TeX-master (filename)
      "Guess the master file for FILENAME from currently open .tex files."
      (let ((candidate nil)
            (filename (file-name-nondirectory filename)))
        (save-excursion
          (dolist (buffer (buffer-list))
            (with-current-buffer buffer
              (let ((name (buffer-name))
                    (file buffer-file-name))
                (if (and file (string-match "\\.tex$" file))
                    (progn
                      (goto-char (point-min))
                      (if (re-search-forward (concat "\\\\input{" filename "}") nil t)
                          (setq candidate file))
                      (if (re-search-forward (concat "\\\\include{" (file-name-sans-extension filename) "}") nil t)
                          (setq candidate file))))))))
        (if candidate
            (message "TeX master document: %s" (file-name-nondirectory candidate)))
        candidate))
(add-hook 'LaTeX-mode-hook
		'(lambda ()
			(setq TeX-master (guess-TeX-master (buffer-file-name)))))

;; turn on Visual Line Mode by default
(global-visual-line-mode t)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)

;; turn on on-the-fly spell checking 
(add-hook 'LaTeX-mode-hook 'flyspell-mode)

;; turn on RefTeX
(add-hook 'latex-mode-hook 'turn-on-reftex)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-auctex t)

;; parenthesis matching as in textmate
;; (1) curl -O http://autopair.googlecode.com/svn/trunk/autopair.el
;; (2) mv autopair.el ~/.emacs.d/autopair/
;; (3) put the following in Preferences.el
(add-to-list 'load-path "~/.emacs.d/autopair") 
   (require 'autopair)
   (autopair-global-mode); enable autopair in all buffers

;; include $-sign in autopair
(add-hook 'TeX-mode-hook
           (lambda ()
              (modify-syntax-entry ?$ "\"")))

####################################################

Now if I have opened example.tex (with or without opened master.tex) and I hit C-c C-c to compile it with latex, I face the following behavior:

(1) Many errors are produced (like \begin{document} is missing etc.). Here is the beginning of the output:

Running `LaTeX' on `example' with ``pdflatex --synctex=1 -interaction=nonstopmode "\input" example.tex''
This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, arabic, armenian, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutch, ukenglish, usenglishmax, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, swissgerman, monogreek, greek, hungarian, icelandic, assamese, bengali, gujarati, hindi, kannada, malayalam, marathi, oriya, panjabi, tamil, telugu, indonesian, interlingua, irish, italian, kurmanji, lao, latin, latvian, lithuanian, mongolian, mongolianlmc, bokmal, nynorsk, polish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, turkish, turkmen, ukrainian, uppersorbian, welsh, loaded.
(./example.tex
! Undefined control sequence.
l.9 \chapter
            {\mytitle}
! Undefined control sequence.
l.9 \chapter{\mytitle
                     }
! LaTeX Error: Missing \begin{document}.
...

(2) A strange behavior is also that instead of stopping after the first error, latex runs and runs until it finally stops with:
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on chapter.log.
LaTeX exited abnormally with code 1 at Thu Sep 15 10:41:36

Is there anything I have missed in the settings? typically, latex should stop after the first error. Then, there should not be any error if master.tex was found correctly.... hmmm... 

Cheers,

Marius




More information about the MacOSX-Emacs mailing list