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 MikTeX and Texmaker to write in.

My issue is that we are a group of people writing the same report, and I want to load the packages we are using from a separate file, or a similar method.

My main document that I am running looks like this:

\PassOptionsToPackage{svgnames}{xcolor}
\documentclass[11pt]{article}

\usepackage{graphicx}  %Grafiske ting

\usepackage{epstopdf}
\usepackage{psfrag}

\usepackage{color, colortbl} %SKAL STÅ FØR LISTINGS
\usepackage[table]{xcolor}

\usepackage{fullpage}
\usepackage{lastpage}
\usepackage{a4wide}   %Smalle marginer
\usepackage{pdfpages}
\usepackage{hyperref}

\usepackage[latin1]{inputenc} %Latin tegn
%\usepackage[Danish]{babel}  % æ ø å %Sætter overskrifter engelsk

\usepackage{booktabs, multicol, multirow}  %Multirows osv i tabeller
\usepackage{fixltx2e}  %excel til latex


\usepackage{subfig}  %Flere figurer
\usepackage{float}   %Gør det muligt at placere figurene det rigtige sted.
\usepackage{subfloat}

\usepackage{amsmath}  %Math - Align osv.
\usepackage{amsfonts}
\usepackage{amssymb}

\numberwithin{equation}{section}
\numberwithin{table}{section}
\numberwithin{figure}{section}

\usepackage{caption}
\usepackage{fancyhdr}
\usepackage{listings}
\lstset{language=Matlab}

\usepackage[numbers]{natbib}
\usepackage{url}
\newcommand{\vis}[1]{\textit{\citeauthor{#1}, \citeyear{#1}} \cite{#1}}
\usepackage{cleveref}



\begin{document}

\makeatletter
\renewcommand\section{\@startsection {section}{1}{0mm}
       {-\baselineskip}{0.1\baselineskip}{\bfseries\large}}
\renewcommand\subsection{\@startsection{subsection}{2}{0mm}%
       {-\baselineskip}{0.1\baselineskip}{\bfseries\normalsize}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{0mm}%
     {-\baselineskip}{0.1\baselineskip}{\bfseries\small}}
\makeatother

\setlength{\belowcaptionskip}{-5pt}
\parindent=0pt
\parskip=1.0ex

\newcommand{\topspace}{\vrule height 15pt width 0pt}

\newcommand{\notetitle}[4]{
    \begin{center}
      {\Large \bf #1}  \\[9pt]
      {\Large \bf #2}  \\[12pt]
      {\large #3}  \\[6pt]
      {\normalsize #4}  \\[36pt]
    \end{center}}



\input{T/Frontpage.tex}  
%\input{T/Abstract.tex}      
%\input{T/Commandoes_Figures.tex}
%\input{T/Commandoes_Math.tex}
%\input{T/Commandoes_Other.tex}
%\input{T/Commandoes_Tables.tex}
\input{T/Preface.tex}
\input{T/Introduction.tex}
%\input{T/Part1.tex}
%\input{T/Part2.tex}
%\input{T/Part3.tex}
\input{T/Part4.tex}
%\input{T/Part5.tex}
%\input{T/Part6.tex}
%\input{T/Part7.tex}
%\input{T/Part8.tex}
%\input{T/Part9.tex}
%\input{T/Part10.tex}
\input{T/Conclusion.tex}

\nocite{*}
\bibliographystyle{unsrtnat}
\bibliography{bibtex}

%\input{T/Appendix.tex}

\end{document}

Now everyone has their own main file and can thereby run only the parts of the report, that they are working with. What I want to do is to have one main file where all the packages and such loaded before the begin document part, are put in, so that if one person wants to add another package, everyone won't have to change this.

If this is a completely ridiculous way of doing it, alternative solutions would be most welcome as well. The main purpose of doing it this way is that everyone can write independently of each other, but are still able to see what everyone else is writing.

Hope the question is clarified properly.

share|improve this question
2  
a4wide is a deprecated package, and also \bf is deprecated. –  egreg Jun 21 '13 at 12:43
1  
From your question I gather you have the subfiles in a central location. You could create a myconfig.sty file, in the same central location and insert there all the \usepackage{whatchacallit} calls and any other global options/definitions. In your main file you would have this one only, i.e. \usepackage{myconfig}. –  Count Zero Jun 21 '13 at 12:43
add comment

2 Answers

up vote 7 down vote accepted

You can make your documents all look like

\documentclass{mylocal}
\begin{document}
\input{T/Frontpage}
...
\end{document}

Then share a mylocal.cls file that looks like

\LoadClass[11pt]{article}

\PassOptionsToPackage{svgnames}{xcolor}

\usepackage{graphicx}  %Grafiske ting

\usepackage{epstopdf}
\usepackage{psfrag}

\usepackage{color, colortbl} %SKAL STÅ FØR LISTINGS
\usepackage[table]{xcolor}

\usepackage{fullpage}
\usepackage{lastpage}
\usepackage{a4wide}   %Smalle marginer
\usepackage{pdfpages}
\usepackage{hyperref}

\usepackage[latin1]{inputenc} %Latin tegn
%\usepackage[Danish]{babel}  % æ ø å %Sætter overskrifter engelsk

\usepackage{booktabs, multicol, multirow}  %Multirows osv i tabeller
\usepackage{fixltx2e}  %excel til latex


\usepackage{subfig}  %Flere figurer
\usepackage{float}   %Gør det muligt at placere figurene det rigtige sted.
\usepackage{subfloat}

\usepackage{amsmath}  %Math - Align osv.
\usepackage{amsfonts}
\usepackage{amssymb}

\numberwithin{equation}{section}
\numberwithin{table}{section}
\numberwithin{figure}{section}

\usepackage{caption}
\usepackage{fancyhdr}
\usepackage{listings}
\lstset{language=Matlab}

\usepackage[numbers]{natbib}
\usepackage{url}
\newcommand{\vis}[1]{\textit{\citeauthor{#1}, \citeyear{#1}} \cite{#1}}
\usepackage{cleveref}



\renewcommand\section{\@startsection {section}{1}{0mm}
       {-\baselineskip}{0.1\baselineskip}{\bfseries\large}}
\renewcommand\subsection{\@startsection{subsection}{2}{0mm}%
       {-\baselineskip}{0.1\baselineskip}{\bfseries\normalsize}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{0mm}%
     {-\baselineskip}{0.1\baselineskip}{\bfseries\small}}
\makeatother

\setlength{\belowcaptionskip}{-5pt}
\parindent=0pt
\parskip=1.0ex

\newcommand{\topspace}{\vrule height 15pt width 0pt}

\newcommand{\notetitle}[4]{
    \begin{center}
      {\Large \bf #1}  \\[9pt]
      {\Large \bf #2}  \\[12pt]
      {\large #3}  \\[6pt]
      {\normalsize #4}  \\[36pt]
    \end{center}}
share|improve this answer
2  
Also \ProvidesClass{mylocal}[YYYY/MM/DD vX.Y My local class] can be added including version date YYYY/MM/DD and number X.Y that also will appear in \listfiles' file list and that will make it easier to identify the latest version of the class. –  Heiko Oberdiek Jun 21 '13 at 13:43
add comment

\input also works in the preamble. You can create a formatsAndDefs.tex file in your working dir that includes all the lines of your preamble and use \input{formatsAndDefs} just before your \begin{document}.

The formatsAndDefs.tex file would look like:

\usepackage{graphicx}  %Grafiske ting

\usepackage{epstopdf}
\usepackage{psfrag}

\usepackage{color, colortbl} %SKAL STÅ FØR LISTINGS
\usepackage[table]{xcolor}

\usepackage{fullpage}
\usepackage{lastpage}
\usepackage{a4wide}   %Smalle marginer
\usepackage{pdfpages}
\usepackage{hyperref}

\usepackage[latin1]{inputenc} %Latin tegn
%\usepackage[Danish]{babel}  % æ ø å %Sætter overskrifter engelsk

\usepackage{booktabs, multicol, multirow}  %Multirows osv i tabeller
\usepackage{fixltx2e}  %excel til latex


\usepackage{subfig}  %Flere figurer
\usepackage{float}   %Gør det muligt at placere figurene det rigtige sted.
\usepackage{subfloat}

\usepackage{amsmath}  %Math - Align osv.
\usepackage{amsfonts}
\usepackage{amssymb}

\numberwithin{equation}{section}
\numberwithin{table}{section}
\numberwithin{figure}{section}

\usepackage{caption}
\usepackage{fancyhdr}
\usepackage{listings}
\lstset{language=Matlab}

\usepackage[numbers]{natbib}
\usepackage{url}
\newcommand{\vis}[1]{\textit{\citeauthor{#1}, \citeyear{#1}} \cite{#1}}
\usepackage{cleveref}

And your main file like this (in your dir structure):

\PassOptionsToPackage{svgnames}{xcolor}
\documentclass[11pt]{article}

\input{T/formatsAndDefs.tex}

\begin{document}
%insert your \include or \input chapters here
\end{document}

Also, you may want to take a look at this topic and might consider switching your \input commands in the main document (i.e. between \begin{document} and \end{document}) to \include commands.

Though a bit slower, they offer the advantage of swithcing only one command to \includeonly, so that the compilation focuses only on the chapter you are working on.

share|improve this answer
    
Note that, usually, we don't include the .tex extension when dealing with \input and friends. –  Sean Allred Jun 22 '13 at 1:15
    
Thanks alot for the awesome suggestions. End up using David Carlisle's file setup and it worked flawlessly! As for the include i might consider it, however as i read it, there is a pagebreak before and after the include parts, and this is not always a good thing in my case. I Might not allways want that. Thanks. –  user32603 Jun 22 '13 at 12:09
add comment

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.