Cleaning my TeX-code
Ideally in the body of a latex document you should have no font or spacing commands, the document should be marking up the document structure with the styling of that structure specified elsewhere. This makes the document far more usable and easy to reformat if you change your mind about the formatting, or send it to a journal and they need to format it to the journal style or if you want to convert to html, or basically any use at all.
Sometimes the ideal is not possible, and for final typeset versions you need to assert control over the system and insert forced spaces and page breaks to get the best quality. That is life and is unavoidable, but such commands should be clearly marked and left to final versions so they can easily be undefined or removed if the document is re-purposed.
Your document isn't so bad (I've seen $$ title $$
used to get centred chapter titles :( but since you ask....
\title{\vspace{-5ex}O...
No:-) The space around title is set in the class, you should be able to redefine that (or just redefine \title
in the preamble) without putting space in the title (which for example in some classes would end up in the/title field in the pdf metadata and other places).
\date{\vspace{-5ex}}
As above.
\maketitle
\vspace{-7ex}
As above.
\subsection{}
\textcolor{black!40}{Tegn produktionsmulighedsområdet på ugebasis for henholdsvis Robinson
og Fredag. Beskriv hvad det angiver.}
\\
Never use \\
at the end of a paragraph, just use a blank line, also explicit colour like explicit font changes is usually a sign that something is wrong. Most likely the markup here should be
\subsection{Tegn produktionsmulighedsområdet på ugebasis for henholdsvis Robinson
og Fredag. Beskriv hvad det angiver.}
With a class/preamble definition of \subsection
that sets its title in an out-dented grey paragraph.
\begin{figure}[ht]
The main effect of [ht]
is to disallow p
which prevents float pages, which massively increases the chance that this float may not be positioned in which case all floats will go to the end of the document. You should almost always include p
if you use the optional argument at all.
\begin{adjustwidth}{1cm}{1cm}
adjustwidth
can be a useful package but the environment shouldn't be used explicitly just used in the definition of a markup with more meaningful document semantics. In fact adjustwidth
(like most LaTeX display environments) is just a one-item list with no label but the indented body. Here you in fact have a list; this indented text is the body with your grey text being the heading or label, so the markup should be using \subsection
as suggested above or a list and using \item
, but either way the relative margins between the number, the grey heading and the indented body should be defined in one place in the top of the document not in every instance.
\end{itemize}
\vspace{1ex}
\noindent Da det ikke
That isn't an unindented paragraph, it is a continuation of the paragraph from before the list. LaTeX goes to a lot of effort to support in-paragraph lists but you have to help it by not adding blank lines which denote end-of-paragraph.
\end{itemize}
Da det
would not be indented.
- In the long run, it would be better to use UTF8 as the input encoding (along with a suitable setting in your editor).
- Don't mess with margins using
\setlength
, unless you really know what you are going. You are much better of using thegeometry
package - Never, never ever use
\\
in the text, in 99.9% of all cases a forced line break is not what you want in the text. - I'd use
\newpage
instead og\pagebreak
. The later stretches the page. - The use of
\vspace
in the text is also a clear sign of »you are doing it wrong« - What is up with all those
adjustwidth
's?
Some hints.
Use as less explicit markup as possible in the document; explicit lengths such as 1cm should be avoided.
Identify how the document is structured and define environments or commands for printing those logical structures.
Be as abstract as possible; for instance, don't hardwire the student's name in the specification for the header line, but define a
\student
command for this.Use high level packages instead of doing things by hand. For instance, use
geometry
for setting the page parameters rather than playing with the internals.Your environments can be defined using standard commands or by hand; using standard commands such as
\subsection
is not a sin, of course; by hiding it in a command (\assignment
) you are free to change it as you wish, if the result is not what you find best.It's not a sin using standard environments such as
itemize
, either. But whenever you start adding formatting instructions to a standard environment, it's time to create your own. This is the case for thebitemize
environment, which prints the items in boldface type.
After the preliminaries, here's a proposal. Note that the changes to the page parameters made useless your \pagebreak
command, which in any case should be possibly added only when the document is in final form and you want to correct bad breaks. Always mark this kind of commands with an easily searchable comment, so that you can remove (or comment out) them when reediting the document.
\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} % or latin1; match the document encoding
\usepackage[danish]{babel}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{scrpage2}
\usepackage[md]{titlesec}
\usepackage{changepage}
\usepackage{xcolor}
\pagestyle{scrplain}
\makeatletter
\ohead[\@student]{}
\makeatother
\cfoot[]{}
\ofoot[\pagemark]{}
\renewcommand{\headfont}{\itshape}
\usepackage{geometry}
\geometry{
margin=2cm,
heightrounded,
headheight=18pt,
headsep=12pt,
}
\renewcommand{\labelitemi}{\raisebox{.4ex}{\tiny$\bullet$}}
\makeatletter
\renewcommand{\@maketitle}{%
{\centering\Large\@title\par}%
\vspace{12pt}%
}
\newcommand{\student}[1]{\gdef\@student{#1}}
\providecommand\@student{No name given}
\makeatother
\newcommand{\assignment}[1]{%
\subsection{}%
{\leavevmode\color{black!40}#1\par}%
}
\newenvironment{image}
{\begin{center}}
{\end{center}}
\newenvironment{solution}
{\begin{adjustwidth}{1cm}{1cm}}
{\end{adjustwidth}}
\newenvironment{bitemize}
{\bfseries\begin{itemize}}
{\end{itemize}}
\begin{document}
\student{Frederik Hestvang, ØP Hold 1}
\title{Obligatorisk opgave 2, x. september 2013.}
\maketitle
\section{Opgave 1}
\assignment{Tegn produktionsmulighedsområdet på ugebasis for henholdsvis Robinson
og Fredag. Beskriv hvad det angiver.}
\begin{image}
\begin{tikzpicture}
\begin{axis}[
scale only axis,
grid=major, grid style={dotted, black!30},
axis lines=middle,
inner axis line style={->},
xlabel={Kartofler},
ylabel={Fisk},
ytick={0,1,...,8},
xtick={0,1,...,8},
ymin=-0.5,
ymax=8,
xmin=-0.5,
xmax=8,
]
\addplot[color=red,thick] coordinates { %ROBINSON
(6, 0)
(0, 6)
};
\addlegendentry{Robinson}
\addplot[color=blue,thick] coordinates { %FREDAG
(3, 0)
(0, 2)
};
\addlegendentry{Fredag}
\addplot[color=black,thick, dotted] coordinates { %HÆLDNINGROB
(2, 4)
(3, 4)
};
\addplot[color=black,thick, dotted] coordinates { %HÆLDNINGROB
(3, 4)
(3, 3)
};
\addplot[color=black,thick, dotted] coordinates { %HÆLDNINGROB
(1, 1.3)
(2, 1.3)
};
\addplot[color=black,thick, dotted] coordinates { %HÆLDNINGROB
(2, 1.3)
(2, 0.66)
};
\node [right] at (axis cs: 3, 3.5) {$-1$};
\node [right] at (axis cs: 2, 1) {$-\frac{2}{3}$};
\end{axis}
\end{tikzpicture}
\end{image}
\begin{solution}
Produktionsmulighedsområdet angiver mængden af de mulige forbrugskombinationer en agent
eller et samfund har. Altså er det her den ramme, som Robinson og Fredag har, at sammensætte
deres produktion af fisk og kartofler indenfor.
\end{solution}
\assignment{Definér begrebet absolutte fordel og argumentér for hvem der har den
absolutte fordel i produktionen af henholdsvis fisk og kartofler?}
\begin{solution}
En producent siges at have absolut fordel i produktion af et gode, hvis denne har en højere
produktivitet (produktion pr. tidsenhed) end den anden producent.
Robinson har den absolutte fordel for begge goder, da hans produktivitet for begge varer er
højere end Fredags.
\end{solution}
%%% Final adjustment
%\pagebreak
\assignment{Definér begrebet alternativomkostninger og argumentér for hvilken sammenhæng der
er mellem produktionsmulighedsområdet (her menes vel transformationskurven?) og begrebet
alternativomkostninger.}
\begin{solution}
Alternativomkostningen ved en handling er værdien af det bedste alternativ, som man må
afgive for at gennemføre en handling. Hældningen på transformationenskurven angiver
alternativomkostningen målt i et gode, ved at producere en enhed mere af et andet gode.
\end{solution}
\assignment{Definér begrebet komparativ fordel og argumentér for hvem der har
den komparative fordel i produktionen af henholdsvis fisk og kartofler. Hvordan
bør Robinson og Fredag specialisere sig ifølge Ricardos teori om komparative
fordele, hvis de skal opnå en gevinst ved at handle med hinanden?}
\begin{solution}
En producent siges at have komparativ fordel hvis denne har den laveste alternativomkostning
ved produktionen af et gode.
Robinsons alternativomkostninger er ens for både fisk og kartofler. Fredags
alternativomkostning ved at producere 1 kilo kartofler mere er $\frac{2}{3}$ kilo kartofler,
og dermed $\frac{3}{2}$ kilo fisk ved at producere 1 kilo kartofler mere (fordi
alternativomkostningen mellem de to varer er reciprok). Altså har\dots
\begin{bitemize}
\item Robsinson den komparativ fordel i produktion af fisk: 1\,kg/kartoffel
\item Fredag komparative fordel i produktion af kartofler: $\frac{2}{3}$\,kg/fisk
\end{bitemize}
Da det ikke er givet, om Robinson eller Fredag har nogle forbrugspræferencer, skal de
specialsere sig fuldt, i den vare de har størst komparativ fordel i. Når de handler, skal
det være i intervallet mellem alternativomkostningerne, altså [$\frac{2}{3}$;1].
\begin{itemize}
\item De kan f.eks\@. handle 1\,kg
\item Robinson: 3\,kg fisk giver 4\,kg kartoffel.
\item Fredag: 2\,kg kartoffel giver 1.5\,kg fisk
\end{itemize}
\begin{image}
\begin{tikzpicture}
\begin{axis}[
scale only axis,
grid=major, grid style={dotted, black!30},
axis lines=middle,
inner axis line style={->},
xlabel={Kartofler},
ylabel={Fisk},
ytick={0,1,...,8},
xtick={0,1,...,8},
ymin=-0.5,
ymax=8,
xmin=-0.5,
xmax=8,
]
\addplot[color=red,thick] coordinates { %ROBINSON
(6, 0)
(0, 6)
};
\addlegendentry{Robinson}
\addplot[color=blue,thick] coordinates { %FREDAG
(3, 0)
(0, 2)
};
\addlegendentry{Fredag}
\addplot[color=blue,thick, mark=*] coordinates { %FREDAG
(1.5, 1.5)
};
\addplot[color=red,thick, mark=*] coordinates { %ROBINSON
(4, 3)
};
\end{axis}
\end{tikzpicture}
\end{image}
\end{solution}
\end{document}