2

I have a number of files that I include in various latex documents (using \include). I thought the best way to keep them in one location would be to put them in a directory under ~/Library/texmf. If I put it right under texmf (~/Library/texmf/Common_stuff) they are not found (even after running texhash). If I put them under ~/Library/texmf/tex/latex it complains that it cannot write the .aux files in that directory. Is there a way of making this work? I am using texlive.

Thanks.

ozsu
  • 2,385
  • For common stuff you should use \input, not \include. – egreg May 08 '15 at 13:20
  • Thank you, but I need to use \includeonly so \input won't work. I don't think that is the problem I am trying to solve anyway -- \input will give the same error. – ozsu May 08 '15 at 13:26
  • Quite strange common stuff, then. What do you have there? – egreg May 08 '15 at 13:31
  • Each of the frames in my beamer presentations are in a different file and then I include them in various presentations and depending on length, I exclude some of them. I would like to maintain these files in a common place. – ozsu May 08 '15 at 13:35
  • also what are you using as the argument to \include you should just use the file name (not the full path) then the aux files will be written to the current directory. – David Carlisle May 08 '15 at 13:36
  • I will try it with that. I was also trying to respond to Blumsohn's answer below, but it won't let me add a comment to it. I wanted to say that using Tex Live Utility, under Actions I do not see Update Filename Database. Am I looking at the wrong place? – ozsu May 08 '15 at 15:45

1 Answers1

1

Using \include and \includeonly is the wrong approach, in my opinion.

If your files are in TEXMFHOME (for TeX Live this means below ~/texmf/tex/latex, unless one is using MacTeX, where it becomes ~/Library/texmf/tex/latex), you don't need to call them by complete path.

Then it's easy to create commands that do similarly to \include and \includeonly without creating .aux files and issuing \clearpage.

\documentclass{article}

\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\commoninclude}{m}
 {
  \clist_gset:Nn \g_ozsu_common_include_clist { #1 }
 }

\NewDocumentCommand{\commoninput}{m}
 {
  \clist_if_in:NnT \g_ozsu_common_include_clist { #1 }
   {
    \input{#1}
   }
 }
\clist_new:N \g_ozsu_common_include_clist
\ExplSyntaxOff

\commoninclude{a,b,d}

\begin{document}

\commoninput{a}

\commoninput{b}

\commoninput{c}

\end{document}

This will just input a.tex and b.tex.

egreg
  • 1,121,712
  • Thank you for this. I'll study this a bit more, but I think I get the gist of it. – ozsu May 08 '15 at 19:08
  • @ozsu I just define a list containing the file names you want to load for this particular task (the list is modifiable. At each \commoninput command, we check whether the requested file is in the list. – egreg May 08 '15 at 19:39
  • Yes, I used it and it works great and does what I wanted without creating far too many .aux files. Many thanks. – ozsu May 09 '15 at 00:59