1

Whenever I begin a document in latex, I have to add a lot of necessary packages such as packages about Tikz or language packages. My quesion is how to creat a quick start which includes some particular packages ?

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{vntex}
\usepackage{graphicx}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{tikz,tkz-tab,tkz-linknodes}
\usetikzlibrary{calc}
\usepackage[width=0.00cm, height=0.00cm, left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\begin{document}
Text...Text
\end{document}

`

  • This question pops up often and the common advice is: every individual document needs an individual preamble. Quick start not recommended. – Johannes_B May 31 '18 at 08:50
  • You can define templates in most editors though. Or simply copy your template file. – Johannes_B May 31 '18 at 08:51
  • In TeXworks you can define so-called templates where you can load a few packages and set up some definitions. See https://tex.stackexchange.com/q/66477/35864 – moewe May 31 '18 at 10:23
  • 1
    Elegant: Make your own class (myclass.cls). Flexible: Make your own pakage (mypackage.sty) . Quick and dirty, but also work: save your preamble to mypreamble.tex and load with \input{mypreamble}. – Fran May 31 '18 at 12:34

2 Answers2

1

My solution to this: create a base file.

I have a folder Tex where all my files are in. I then have the _Base folder where I have a Base.tex file in it. There, I've defined all basic infos such as header etc. such that they look the same in every document plus environments / commands I reuse. You can then use this Base.tex file with \input{}.

\documentclass[a4paper,10pt]{scrartcl} 
\input{../_Base/Base.tex}
\begin{document}
text
\end{document}

What my base document looks like (partly):

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tocloft,
    graphicx,
    hyperref,
    calc,
    listings,
    longtable
}
\usepackage[table,xcdraw]{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\usepackage[headsepline,automark]{scrlayer-scrpage}
\usepackage[top=3cm, bottom=3cm,headheight=27pt]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Colours
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{PatheYellow}{HTML}{FFC426}
\definecolor{PatheSilver}{HTML}{A7A9AC}
\definecolor{PatheGrey}{HTML}{707174}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\colorlet{punct}{red!60!black}
Shade
  • 443
  • 2
  • 10
1

The proper way to do it is to write your own custom package (named customizeme for example), guidelines are here : https://fr.sharelatex.com/learn/Writing_your_own_package

Then once it's installed you'll juste have to do the old \usepackage{customizeme} and that'll do the trick.

Or if you want you can also write you're very own style, which is more work but also more glory ^^