Math & ScienceWhat is wrong with the use of \vspace{} here?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
lo2
Posts: 15
Joined: Wed Oct 21, 2009 6:31 pm

What is wrong with the use of \vspace{} here?

Post by lo2 »

Hey I written the following piee of LaTeX code:

Code: Select all

\documentclass[danish]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\usepackage{units}
\usepackage{babel}
\usepackage{ae}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage[pdftex]{graphicx}
\geometry{verbose,letterpaper,bmargin=2cm,tmargin=2cm}
\pagestyle{fancy}
\title{-}
\author{-}
\fancyhead[LE,RO]{side \thepage  $\ $/ \pageref{LastPage} -- \LaTeX}
\chead{}
\lhead{-}
\begin{document}
\section{-}
\tableofcontents{} 
\subsection{Opgave 1}
Jeg har følgende data for løbedistancen i km og løberens tid på distancen, for en kondiløber:
\begin{center}
\begin{tabular}{ | p{3cm} | l | l | 1 | 1 |}
\hline
Løbedistance (km) & 5 & 10 & 15 & 20\\ \hline
Løberens tid på distancen (sek.) & 1024 & 2136 & 3282 & 4453\\ 
\hline
\end{tabular}
\end{center}
Jeg får så at vide at kondiløberens tid som funktion af distancen, har følgende sammenhæng:
\[
f(x)=b\cdot x^a
\]
Hvor $x$ er distancen i kilometer (km) og $f(x)$ er kondiløberens tid målt i sek.
\vspace{0.5 cm}
a)
\vspace{0.5 cm}
Bestememr tallene $a$ og $b$ via potentiel regression, og jeg får:
\[
f(x)=185,8974078\cdot  x^{1,060225667}
\]
\vspace{0.5 cm}
b)
\vspace{0.5 cm}
Jeg skal så via $f$ bestemme kondiløberesn tid på en marathon, som jo er 42,195 km. Med andre ord skal jeg bestemme $f(42,195)$. Jeg sætter så ind i min forskrift:
\[
f(42,195)=185,8974078\cdot  (42,195)^{1,060225667}=9826,904882\approx 9826 \unit{sek.}
\]
\end{document}
So when I convert into a pdf, the part around b) does not look the way it should, how come? And how to fix it?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

What is wrong with the use of \vspace{} here?

Post by Stefan Kottwitz »

lo2 wrote:the part around b) does not look the way it should, how come? And how to fix it?
You could tell us, how it should look. ;-)
Perhaps you would like to end the line, before you add vertical space? In that case, this would work:

Code: Select all

b)\\
\vspace{0.5 cm}
Even easier is using the optional argument of the line breaking macro, such as

Code: Select all

b)\\[0.2cm]
Btw. repeated use of \vspace shows that the document design could be improved, repeated manual corrections should rarely be necessary in a structured document.

Stefan
LaTeX.org admin
lo2
Posts: 15
Joined: Wed Oct 21, 2009 6:31 pm

Re: What is wrong with the use of \vspace{} here?

Post by lo2 »

May I ask what you would have done differently, so that you would not have to create these vertical spaces?
lo2
Posts: 15
Joined: Wed Oct 21, 2009 6:31 pm

What is wrong with the use of \vspace{} here?

Post by lo2 »

Also may I ask what is wrong with this table:

Code: Select all

[url]\begin{center}
\begin{tabular}{ | p{3cm} | l | l | 1 | 1 |}
\hline
Løbedistance (km) & 5 & 10 & 15 & 20\\ \hline
Løberens tid på distancen (sek.) & 1024 & 2136 & 3282 & 4453\\ 
\hline
\end{tabular}
\end{center}[/url]
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

What is wrong with the use of \vspace{} here?

Post by Stefan Kottwitz »

lo2 wrote:May I ask what you would have done differently, so that you would not have to create these vertical spaces?
I would use a LaTeX environment, such as the {enumerate} environment, and customize it, either with LaTeX spacing settings or with the enumitem package.

Or I would define my own environment.

In any way, I would define this just once in the preamble, valid for the whole document. Whenever I would like to adjust that spacing, only a modification of the preamble would be needed.

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

What is wrong with the use of \vspace{} here?

Post by Stefan Kottwitz »

lo2 wrote:Also may I ask what is wrong with this table
You accidently wrote 1 (one) instead of l (the letter). With some fonts it's hard to distinguish.

Stefan
LaTeX.org admin
Post Reply