我有多个文件,每个文件都正确引用主文件,并且可以毫无问题地编译文档.... 只能在主文件中说明时RefTeX
引用环境,,figures
等...而不是这个equations
C-c )
主文件以外的任何其他文件中都看不到其他标签...请指教。
以下是最小文件
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
\documentclass{book}
\begin{document}
\chapter{chapter 1 }
\label{cha:chapter-1}
\ref{cha:chapter-1}
\end{document}
第二个文件slave.tex
\chapter{Chapter 2 }
\label{cha:chapter-2}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "master"
%%% End:
init.el
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-save-query nil)
(setq TeX-PDF-mode t)
(setq-default TeX-master nil)
(require 'tex-site)
(setq reftex-enable-partial-scans t)
(setq reftex-save-parse-info t)
(setq reftex-use-multiple-selection-buffers t)
(setq reftex-plug-into-AUCTeX t)
(autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
(autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
(autoload 'reftex-label "reftex-label" "Make label" nil)
(autoload 'reftex-reference "reftex-reference" "Make label" nil)
(autoload 'reftex-citation "reftex-cite" "Make citation" nil)
(autoload 'reftex-index-phrase-mode "reftex-index" "Phrase Mode" t)
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
;(add-hook 'reftex-load-hook 'imenu-add-menubar-index)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq LaTeX-eqnarray-label "eq"
LaTeX-equation-label "eq"
LaTeX-figure-label "fig"
LaTeX-table-label "tab"
LaTeX-myChapter-label "chap"
TeX-auto-save t
TeX-newline-function 'reindent-then-newline-and-indent
TeX-parse-self t
TeX-style-path
'("style/" "auto/"
"/usr/share/emacs21/site-lisp/auctex/style/"
"/var/lib/auctex/emacs21/"
"/usr/local/share/emacs/site-lisp/auctex/style/")
LaTeX-section-hook
'(LaTeX-section-heading
LaTeX-section-title
LaTeX-section-toc
LaTeX-section-section
LaTeX-section-label))
(eval-after-load
"latex"
'(TeX-add-style-hook
"cleveref"
(lambda ()
(if (boundp 'reftex-ref-style-alist)
(add-to-list
'reftex-ref-style-alist
'("Cleveref" "cleveref"
(("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
(add-to-list 'reftex-ref-style-default-list "Cleveref")
(TeX-add-symbols
'("cref" TeX-arg-ref)
'("Cref" TeX-arg-ref)
'("cpageref" TeX-arg-ref)
'("Cpageref" TeX-arg-ref)))))
(add-to-list 'load-path "/home/msalem/.emacs.d/predictive")
(add-to-list 'load-path "/home/msalem/.emacs.d/predictive/latex")
(add-to-list 'load-path "/home/msalem/.emacs.d/predictive/texinfo")
(add-to-list 'load-path "/home/msalem/.emacs.d/predictive/misc")
(add-to-list 'load-path "/home/msalem/.emacs.d/predictive/html")
(require 'predictive)
(setq predictive-main-dict 'rpg-dictionary
predictive-auto-learn t
predictive-add-to-dict-ask nil
predictive-use-auto-learn-cache nil
predictive-which-dict t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-source-correlate-method (quote synctex))
'(TeX-source-correlate-start-server t)
'(TeX-view-program-list (quote (("Okular" "okular -unique %o#src:%n%b"))))
'(TeX-view-program-selection (quote ((output-pdf "Okular") ((output-dvi style-pstricks) "dvips and gv") (output-dvi "xdvi") (output-pdf "Evince") (output-html "xdg-open"))))
'(inhibit-startup-screen t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
引用只能看到主文件中的标签,而 Cc ) 从从属文件调用时无法识别同一文件中章节的标签.....;; 如果有多个,它们将无法正常工作。)
编辑 1:忘记提到我导入并从属文件并将其包含在主文件中。这对我来说相当复杂,因为有了这个最小文件,我能够引用主文件中或从属文件中存在的任何内容。在我正在构建的主文档中,我只能引用主文件中的内容!
编辑 2:问题主要在于使用\import
来包含文件,而不是。我还注意到每次尝试添加新文件时\input
都需要重置。我也会尝试检查它是否在新方案中更新。我还将继续使用您发送的...再次感谢 Jon,我非常感谢您的反馈和解决方案...RefTex
\cite
init.el
答案1
基本问题是主文件实际上并没有引用所谓的子文件,因此不可能任何程序要知道它需要考虑主文件-子文件关系。在 AUCTeX 的情况下,解析工作是从子文件进行的,因为它有一个变量通知 AUCTeX 主文件(但您会注意到 AUCTeX/RefTeX 不会解析子文件本身,因此它几乎没有用处)。
\include
但如果你这样做或\input
将文件放入子文件中,事情就会按预期进行。例如:
主文件
\documentclass{book}
\begin{document}
\chapter{chapter 1}
\label{cha:chapter-1}
\input{subfile}% <-- crucial!
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
子文件
\chapter{Chapter 2}
\label{cha:chapter-2}
\label{anotherlabel}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "masterfile"
%%% End:
现在C-c ) <SPC>
应该给出一个(在本例中)三个标签的列表。这甚至可以与init
上面提供的文件一起使用,尽管我不得不注释掉一些内容。您可以使用以下内容进行测试(假设提供的文件名为myinit.el
):
emacs -q -l myinit.el masterfile.tex
我的初始化文件
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-save-query nil)
(setq TeX-PDF-mode t)
(setq-default TeX-master nil)
(require 'tex-site)
(setq reftex-enable-partial-scans t)
(setq reftex-save-parse-info t)
(setq reftex-use-multiple-selection-buffers t)
(setq reftex-plug-into-AUCTeX t)
(autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
(autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
(autoload 'reftex-label "reftex-label" "Make label" nil)
(autoload 'reftex-reference "reftex-reference" "Make label" nil)
(autoload 'reftex-citation "reftex-cite" "Make citation" nil)
(autoload 'reftex-index-phrase-mode "reftex-index" "Phrase Mode" t)
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
(add-hook 'reftex-load-hook 'imenu-add-menubar-index)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq LaTeX-eqnarray-label "eq"
LaTeX-equation-label "eq"
LaTeX-figure-label "fig"
LaTeX-table-label "tab"
LaTeX-myChapter-label "chap"
TeX-auto-save t
TeX-newline-function 'reindent-then-newline-and-indent
TeX-parse-self t
TeX-style-path
'("style/" "auto/"
"/usr/share/emacs21/site-lisp/auctex/style/"
"/var/lib/auctex/emacs21/"
"/usr/local/share/emacs/site-lisp/auctex/style/")
LaTeX-section-hook
'(LaTeX-section-heading
LaTeX-section-title
LaTeX-section-toc
LaTeX-section-section
LaTeX-section-label))
(eval-after-load
"latex"
'(TeX-add-style-hook
"cleveref"
(lambda ()
(if (boundp 'reftex-ref-style-alist)
(add-to-list
'reftex-ref-style-alist
'("Cleveref" "cleveref"
(("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
(add-to-list 'reftex-ref-style-default-list "Cleveref")
(TeX-add-symbols
'("cref" TeX-arg-ref)
'("Cref" TeX-arg-ref)
'("cpageref" TeX-arg-ref)
'("Cpageref" TeX-arg-ref)))))
;; NOTE: the following lines are commented out:
;; (add-to-list 'load-path "/home/msalem/.emacs.d/predictive")
;; (add-to-list 'load-path "/home/msalem/.emacs.d/predictive/latex")
;; (add-to-list 'load-path "/home/msalem/.emacs.d/predictive/texinfo")
;; (add-to-list 'load-path "/home/msalem/.emacs.d/predictive/misc")
;; (add-to-list 'load-path "/home/msalem/.emacs.d/predictive/html")
;; (require 'predictive)
;; (setq predictive-main-dict 'rpg-dictionary
;; predictive-auto-learn t
;; predictive-add-to-dict-ask nil
;; predictive-use-auto-learn-cache nil
;; predictive-which-dict t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-source-correlate-method (quote synctex))
'(TeX-source-correlate-start-server t)
'(TeX-view-program-list (quote (("Okular" "okular -unique %o#src:%n%b"))))
'(TeX-view-program-selection (quote ((output-pdf "Okular") ((output-dvi style-pstricks) "dvips and gv") (output-dvi "xdvi") (output-pdf "Evince") (output-html "xdg-open"))))
'(inhibit-startup-screen t))
;(custom-set-faces <-- COMMENTED; otherwise file won't load properly
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.