1

I write

{\documentclass[10pt]{report}

\usepackage{xcolor}
\usepackage{geometry}
\usepackage[pdftex,bookmarks=true]{hyperref}
\usepackage{pdfpages}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{tikz-cd}
\usetikzlibrary{cd}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}

\definecolor{bluegreen}{rgb}{0,.3,2}

\titleformat{\chapter}[display]
  {\normalfont\huge}
  {\hspace*{-70pt}\thechapter.~#1}
  {-15pt}
  {\hspace*{-110pt}\rule{\dimexpr\textwidth+30pt\relax}{1pt}}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont}
  {\hspace*{-70pt}#1}
  {-15pt}
  {\hspace*{-110pt}\rule{\dimexpr\textwidth+30pt\relax}{0pt}}
\titlespacing*{\chapter}{0pt}{0pt}{30pt}    

\geometry{
top=10mm,
total={145mm,230mm}
}

\hypersetup{
    colorlinks=true,
    linkcolor=bluegreen,
    filecolor=magenta,      
    urlcolor=cyan,
    pdftitle={Sharelatex Example},
    bookmarks=true,
    pdfpagemode=FullScreen,
}

\tikzset{>=stealth}
}

everytime i start a LateX document is there anyway to combine them into one package?

10
  • Making an one .sty file importing with \usepackage{...} and other stuff, without the \documentclass of course? -- The {\documentclass... troubles me,however
    – user31729
    Oct 19, 2015 at 15:43
  • How to make one .sty file?
    – MrPajeet
    Oct 19, 2015 at 15:44
  • 2
    @bgr95 but hopefully you never need lipsum in a real document. Oct 19, 2015 at 15:49
  • 1
    @bgr95 anywhere in your input tree: just put it in the same directory as your document initially, till you get it working Oct 19, 2015 at 15:50
  • 7
    @bgr95 including lots of packages you do not use is generally a bad idea. It has all the problems of slowing things down and risking weird errors due to package interactions, for no gain. Much better to just add packages as you need them. Oct 19, 2015 at 15:52

1 Answer 1

7

Short way:

Make a file named, say mypackages.tex and copy all the \usepackage{...} statements and other stuff into that one.

In your real document use \documentclass[10pt]{report} and \input{mypackages} before \begin{document}...\end{document}

Longer way:

Make a file named mypackages.sty with this content:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mypackages}

\RequirePackage{foo}
\RequirePackage{bar}

% Other stuff from your frequent used files

\endinput

Place this file either in your local working directory or in a local texmf directory (depends on the distribution/operating system)

In your real document you can use

\documentclass[10pt]{report}
\usepackage{mypackages}

\begin{document}
....
\end{document}

In all cases replace \documentclass[10pt]{report} by the real settings -- it's only an example here!

6
  • 2
    \documentclass{yourclass}: Do you mean <whatever class you are using> or a custom class? At present it might be a bit confusing whether the instructions show how to make a .sty package or a .cls class. Oct 19, 2015 at 22:56
  • @AndrewCashner: Good point, thanks -- I changed it to the class mentioned in the post
    – user31729
    Oct 20, 2015 at 4:19
  • I don't have \NeedsTeXFormat in any of my packages…
    – cgnieder
    Oct 20, 2015 at 9:39
  • @clemens: Your packages do not comply to any standard: They are outstanding :-P
    – user31729
    Oct 20, 2015 at 14:19
  • I wanted to do this: Since I use windows I created a folder C:\Users\xyz\texmf\tex\latex where I saved my .sty file and everything works
    – MrPajeet
    Nov 28, 2015 at 11:27

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.