In theory, you don't have to do anything to make it work. You should have included a minimal example providing info on how your document is structured. Suppose your document is structured as follows.
\documentclass[a4paper]{article}
\usepackage{breqn}
\begin{document}
\begin{dmath}
f(x)=\frac{1}{x} \condition{for \(x\neq 0\)}
\end{dmath}
\end{document}
Then all you need to do is to execute TeX-normal-mode
(C-c C-n
) to force the generation of automatic local styles in the auto/ directory relative to the current directory. The auto local style is only needed to be generated once if no further package is to be added to your preamble. The following is the generated file.
(TeX-add-style-hook
"tmp"
(lambda ()
(TeX-add-to-alist 'LaTeX-provided-class-options
'(("article" "a4paper")))
(TeX-run-style-hooks
"latex2e"
"article"
"art10"
"breqn"))
:latex)
You can have a very good guess on what the above code mean. If your document is structered in the following way instead, you might have to do more to make it work.
\documentclass[a4paper]{article}
\input{my-custom-preamble}
\begin{document}
\begin{dmath}
f(x)=\frac{1}{x} \condition{for \(x\neq 0\)}
\end{dmath}
\end{document}
Assume my-custom-preamble.tex in the current directory is a preamble file you maintained for your own use across many files and the breqn
package is loaded via this file instead of the document you are editing. Then the automatically generated local style would be as follows.
(TeX-add-style-hook
"tmp"
(lambda ()
(TeX-add-to-alist 'LaTeX-provided-class-options
'(("article" "a4paper")))
(TeX-run-style-hooks
"latex2e"
"my-custom-preamble"
"article"
"art10"))
:latex)
It tries to load the my-custom-preamble.el style file but this is unknown to AUCTeX. In this case, create a my-custom-preamble.el with the following content, either in the style/ directory (TeX-style-local
) relative to the current directory or in ~/.emacs.d/auctex/style/ directory (TeX-style-private
).
(TeX-add-style-hook
"my-custom-preamble"
(lambda ()
(TeX-run-style-hooks
"breqn"))
:latex)
You get the idea behind it. And this is the way to do it for most common packages since the styles for them are predefined in the ~/.emacs.d/elpa/auctex-/style/ directory (TeX-style-global
). If you use some packages for which there are no predefeind correspondent style files in that directory, then you have two ways. You can run M-x TeX-auto-generate-global
to generate automatic global styles for all the packages found in the TeX distribution installed on your computer. This is time-consuming and generate style files with byte-compiled files totaling around 100 MiB in the TeX-auto-global
directory. Or you can generate the file on a package-by-package basis with the TeX-auto-generate
command.
Finally, your setup might be different from mine resulting in different directories being used. Check your TeX-style-path
, TeX-style-local
, and relevant variables.
As a gentle reminder, you should never do the following. Most functionality of AUCTeX will fail for such documents without \documentclass{...}
.
\input{my-custom-preamble}
\begin{document}
<The content of your document>
\end{document}