Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using AucTeX in emacs v23 in PFD-mode. When invoking the pdflatex compiler through C-c C-c LaTeX I get a [...] file <some_package>.sty not found error for some particular packages. For example, consider the following foo.tex file:

\documentclass{article}

\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithm}
  \caption{Some advanced stuff here.}
  \begin{algorithmic}
    \Function{Increment}{$x$}
    \State \Call{Return}{$x+1$}
    \EndFunction
  \end{algorithmic}
\end{algorithm}

\end{document}

Compiling the file using AucTeX (C-c C-c LaTeX) yields:

ERROR: LaTeX Error: File `algpseudocode.sty' not found.

However, if I invoke pdflatex foo.tex via the terminal, everything works alright.

The only packages I have so far experienced this behavior with are algpseudocode and fmtcount, included in the Linux packages texlive-science and texlive-latex-extra, respectively. The packages are, apparently, there; for example, I get the following in the terminal:

$ locate -b fmtcount.sty
/usr/share/texmf-texlive/tex/latex/fmtcount/fmtcount.sty
$ dpkg -l | grep texlive-latex-extra
ii  texlive-latex-extra      2009-10ubuntu1           TeX Live: LaTeX  supplementary packages
ii  texlive-latex-extra-doc  2009-10ubuntu1           TeX Live: Documentation files for texlive-latex-extra

What I find particularly confusing is that I get no such error for package footmisc, which is also part of texlive-latex-extra.

(Please bear in mind that I do not have root access in the machine I'm experiencing this problem at. If it is needed, I can ask the administrators to do the fix - once I know what that might be - but I doubt they'd be willing to start attempting various approaches to it.)


Update

$ kpsewhich algpseudocode.sty
/auto/pkg/texlive-2009/texmf-dist/tex/latex/algorithmicx/algpseudocode.sty

It appears that the problem is caused by the pdflatex program invoked by AucTeX. As I mentioned above, if I run pdflatex foo.tex manually through the terminal, it works, and the first line of foo.log is:

This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009) (format=pdflatex 2010.6.1)  15 FEB 2012 17:15

If, on the other hand, I invoke the compiler through C-c C-c LaTeX in AucTex, the foo.log file is as follows (notice the difference between the TeX distributions seen in the first line):

This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=pdflatex 2011.4.5)  15 FEB 2012 13:24
entering extended mode
**\input foo.tex
(./foo.tex (/auto/pkg/tetex-3.0/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard LaTeX document class
(/auto/pkg/tetex-3.0/share/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2004/02/16 v1.4f Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/auto/pkg/tetex-3.0/share/texmf-dist/tex/latex/algorithms/algorithm.sty
Package: algorithm 

Document Style `algorithm' - floating environment
(/auto/pkg/tetex-3.0/share/texmf-dist/tex/latex/float/float.sty
Package: float 2001/11/08 v1.3d Float enhancements (AL)
\c@float@type=\count87
\float@exts=\toks14
\float@box=\box26
\@float@everytoks=\toks15
\@floatcapt=\box27
)
(/auto/pkg/tetex-3.0/share/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
)
\@float@every@algorithm=\toks16
\c@algorithm=\count88
)

! LaTeX Error: File `algpseudocode.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 

l.5 ^^M

*** (cannot \read from terminal in nonstop modes)


Here is how much of TeX's memory you used:
 346 strings out of 94499
 4143 string characters out of 1173445
 49441 words of memory out of 1000000
 3593 multiletter control sequences out of 10000+50000
 3640 words of font info for 14 fonts, out of 500000 for 2000
 580 hyphenation exceptions out of 1000
 23i,0n,17p,157b,36s stack positions out of 1500i,500n,5000p,200000b,5000s
PDF statistics:
 0 PDF objects out of 300000
 0 named destinations out of 131072
 1 words of extra memory for PDF output out of 65536
No pages of output.

I'm afraid I can't figure out how to point AucTeX to the correct pdflatex installation, though.

In case it's useful, I have the following AucTeX-related lines in my .emacs file:

(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook
          (lambda ()
            (TeX-fold-mode 1)))
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
share|improve this question
2  
Could it be that Emacs is picking up a different latex installation? Auctex just calls pdflatex or whatever and so missing package messages are likely to be from pdflatex, not auctex. –  PLK Feb 15 '12 at 19:27
    
We could do to see the .log file you get. Also, what does kpsewhich algpseudocode.sty give? –  Joseph Wright Feb 15 '12 at 19:37
1  
We'd like to keep answers separate from questions, so you should write a separate answer instead of editing your answer into the question. Self-answers are perfectly admissible, and a well-written answer may earn you additional reputation. –  lockstep Feb 21 '12 at 22:55
1  
@Sweeters: It shouldn’t be necessary to edit /etc/environment. Adjust the PATH in ~/.profile and restart the X server. ~/.profile is sourced during text as well as graphical login. Note that, in general, it is not a good idea to set environment variables such as PATH in ~/.bashrc. Use ~/.profile for this purpose. –  mhp Feb 22 '12 at 8:32
1  
@Sweeters: Check the system PATH exported in /etc/profile or /etc/environment, prepend the directories you additionally need to the system PATH in ~/.profile, ensure that neither ~/.bash_profile nor ~/.bash_login exist, ensure that the PATH is not modified either in /etc/bash.bashrc or ~/.bashrc, and, finally restart the display manager. Then the resulting PATH should be independent of the login mode. –  mhp Feb 22 '12 at 20:07

1 Answer 1

up vote 6 down vote accepted

The problem was being caused by invoking Emacs through the Gnome panel, which results in Emacs being oblivious of the PATH as it is set through .bashrc.

A way to fix this is to have Emacs set its PATH to be the one seen by bash, by putting the following in the .emacs file (credit to Shane in here):

(setenv “PATH” (shell-command-to-string “bash -i -c ‘echo -n $PATH’”))
share|improve this answer
    
Undoubtedly, this is a working fix. But the actual problem is that the PATH is set in ~/.bashrc (the initialization script for non-login interactive Bash), which means that applications such as Emacs might see a different environment, depending on whether they are invoked from a text or graphical terminal. –  mhp Feb 23 '12 at 8:25
    
Indeed you are right, mhp; and I would generally prefer the solution you posted above. The problem I have with avoiding setting the PATH through .bashrc is that there is a "central" .bashrc file that's being sourced for all workstations in the network and I can only add my own customizations on top of that. Of course, I could ask that I self-administer my workstation, and then make sure that such customizations are set in the proper, so to speak, places, but then that might create a series of other complications I'd rather not deal with at the time. –  Sweeters Feb 24 '12 at 16:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.