# Beamer themes on custom folder

EDIT after closing question: the referenced answers say how to install the themes by putting theme in an appropriate tex folder. But this is not what I am asking, I want to be able to "pack and ship" my theme together with other tex files so that other users are able to use them without doing anything. Like custom packages.

I have created a custom Beamer theme. This is defined in the file beamerthemeMYTHEME.sty. As usual, this file calls three more files namely

beamercolorthemeMYTHEME.sty, beamerinnerthemeMYTHEME.sty and beamerouterthemeMYTHEME.sty.

If my .tex is in the same directory as the theme files, I can use the theme only by \usetheme{MYTHEME}.

Next, if I put these files in a directory (Theme) I must use \usepackage{Theme/beamerthemeMYTHEME.sty}. HOWEVER it seems that the other files cannot be found as I get the error

beamerinnerthemeMYTHEME.sty' not found. \useinnertheme{MYTHEME}.

I want to use this approach as I expect other people to use these theme.

Is there any way to make this work?

Besides handling the theme files, it would also be interesting how to best incorporate graphics from subfolders with things like \pgfdeclareimage

• No, I am asking how to call the theme files from whichever directory I want. Not how to "install them". So, it is not a duplicate. – PepeToro Oct 30 '15 at 8:09
• I voted to reopen because beamer is special and it might be good for the audience. However, if you reverse engineering the answers in the other question, you will understand what to do (as a matter of fact, it is a duplicate). – Claudio Fiandrino Oct 30 '15 at 9:00
• – Ignasi Dec 21 '15 at 16:41
• You can package the theme as a TDS archive such that Beamer will be able to find things if users install the archive into a suitable TeXMF tree in the usual way. I'm not clear this is what you want to do, though. (The answer below suggests not. However, I am not at all sure that it is appropriate to redefine Beamer's internal commands - certainly that would require flagging up in your package's documentation and it could not longer be called simply a 'theme' without being deeply misleading.) – cfr Dec 22 '15 at 0:05

All \use[xxx]theme are implemented by a \usepackage. For example \usetheme{MYTHEME} is expanded to \usepackage{beamerthemeMYTHEME}.

If one want to modify the behavior of \usepackage or its family (that they do not search subfolders), it is no longer related to Beamer.

A way inside beamer is to redefine

  \def\beamer@calltheme#1#2#3{%
\def\beamer@themelist{#2}
\@for\beamer@themename:=\beamer@themelist\do
{\usepackage[{#1}]{#3\beamer@themename}}}


To something like

\makeatletter
\def\beamer@calltheme#1#2#3{%
\def\beamer@themelist{#2}
\@for\beamer@themename:=\beamer@themelist\do
{\input{Theme/#3\beamer@themename.sty}}}


Then TeX will search the subfolder Theme for beamerthemeMYTHEME.sty.

Perhaps a better way is to invent new macros. For example

\makeatletter
\def\beamer@calltheme#1#2#3{%
\def\beamer@themelist{#2}
\@for\beamer@themename:=\beamer@themelist\do
{\usepackage[{#1}]{\beamer@themelocation/#3\beamer@themename}}}

\def\usefolder#1{
\def\beamer@themelocation{#1}
}
\def\beamer@themelocation{}


Now

\usefolder{Theme}
\usetheme{MYTHEME}


will give the desired result. For sub-subfolders, use grouping

{
\usefolder{Theme/ColorTheme}
\usecolortheme{abc}
}


One might want to implement \gotosubfolder{ColorTheme} to replace \usefolder{Theme/ColorTheme}. But seriously, this is barely related to Beamer.

• This indeed solves my problem. I guess whether redefining internal Beamer commands is good or bad is another issue. But I think, since this is being done only for the beamer file to be created and shipped, it shouldn't be that bad ... Thanks! – PepeToro Dec 22 '15 at 13:57
• @Symbol. This gives LaTeX Error: file theme/beamerfontthemedefault.sty' not found and Fatal error occurred, no output PDF file produced! as it causes the compiler to search for beamerthemedefault.sty inside /usr/local/texlive/.../beamer/themes/theme instead of one level up. – PatrickT May 18 '17 at 16:30
• @PatrickT Maybe you should ask a followup question and include a MWE. According to information you gave, I suppose that the theme you are including tries to include another theme. This will confuse LaTeX since it is unclear where to find the second theme. The proper solution depends on the situation. For instance is the first theme editable? Is the preamble of .tex file editable? etc. – Symbol 1 May 18 '17 at 16:49
• @Symbol1, thanks for your reply. Yes, the custom theme contains a line like \useoutertheme{default}` I see the problem, thanks. – PatrickT May 18 '17 at 17:00