7

I think that what I would like to do is a class file, however beamer is a latex class, so I'll try the long description:

I have written quite a few commands to make a beamer document look the way I like. I have to actually write some more and add conditionals so that it can look in one of the two ways I like, and allow to configure it, and configure the colors (theme?). I would like to put all those commands in a single file so that it is easy to reuse (by me and possibly other people, if they are fear no errors or bugs).

AFAIK, a document has only one class, therefore I should do something different.

I think it may be possible to define a .sty file and use it with \usepackage, this would allow to use options to configure the behaviour of the poorly written and insanely overcomplicated file. I may be wrong, though.

The question is twofold: What should I do and how can I do that?

For the first, I guess it's a .sty but I may be completely wrong, for the second, the url of a tutorial or example would probably be the best option.

Thank you.

7

I recommend opening an existing theme and seeing how it's done. Experimenting works here quite well I would say. The themes are usually located in <TeX root>/tex/latex/beamer/themes/theme/. Remember to put your new style in the folder where you document is and give the file a name beamertheme<Theme Name>.sty

  • Thank you. I'm trying to do that, first problem I found is that I'd like to define the colors (I'm doing that in a separate file now beamercolortheme<Name>.sty), for the colors I was using the package xcolor but I found no \usepackage commands in the themes so far. Is \usepackage ok in this context? – Trylks Oct 4 '13 at 14:12
  • You can use \usepackage there, you can do the same as in the document preamble. However, AFAIK xcolor is loaded by default in beamer. – yo' Oct 4 '13 at 15:07
0

I second what @tohecz states. However, I would like to add that (when using mktex) I needed to issue 'sudo mktexlsr' in order to make this work right away. I believe that this is similar to sourcing a .bashrc, but maybe someone above my $\TeX$ paygrade can comment on exactly what this command does.

EDIT:

I do not actually second this. I misread the given solution. This would work if you would like to place duplicate .sty files all over, but (although it may be frowned upon) I like to be able to just import my beamer themes as if they were defaults. If you place your style file (imagine it is named beamerthemeMySty.sty) in /usr/share/texmf/tex/latex/beamer/base/themes/theme (that was my install, your root may be different) then you can simply include \usetheme{MySty} in your document and not have to worry about having a copy of your style file in your CWD.

As mentioned, this may be frowned upon (not sure why, you are simply adding a new .sty file to a directory full of other .sty files) but it works. This has worked just fine for me through multiple upgrades of my OS and I have never had any issues.

And to answer your question, yes you may import other packages into your .sty files. See the existing themes for how this should properly be done.

  • No, you have it wrong. You of course need to do this, but only if you place the new file in the texmf tree, which is frowned upon. If you read my answer carefully, you would see that I advise to put the file where the document is, and then you never need mktexlsr. – yo' Oct 4 '13 at 13:57
  • Hmm, oh. So you would suggest placing a copy of the style file in each new project directory? If so, I would say this seems unnecessary. Why not just create a new style file inside the /usr/share/texmf/tex/latex/beamer/base/themes/theme directory (on my machine..root may be different depending on installation) and then you can import it from anywhere without having to place duplicates all over my machine. – codeAndStuff Oct 4 '13 at 14:28
  • Never even manually modify your texmf tree! But remember that each time you use a user-made file this way, your project is ready to be un-portable. Once you'll find that you want to make a small change in your talk and you'll find that yes, you have your .tex file, but the .sty file is missing. As well, people tend to make small changes to the style from project to project, and this makes the idea of the global style almost impossible. – yo' Oct 4 '13 at 15:05
  • btw, you probably exchanged \usepackage{MySty.sty} (which is incorrect anyways since you don't write down the extension) with \usetheme{MySty}. – yo' Oct 4 '13 at 15:10
  • Ah yes, I do mean \usetheme{MySty}, edit made. Thank you. What do you mean by having my .tex file but not the .sty file? I never have any issues (obvious by the fact that I am not even sure what you problem you may be referring to). As per the small changes from talk to talk, sure. But if you do not (I tend to keep a theme for at least a semester at a time, especially in presentation-intensive courses, etc..) then this can be a handy thing to have available IMO. – codeAndStuff Oct 4 '13 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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