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 writing a document with some odd spacing. I am copying another document, and therefrore the layout must be almost exact. I have sections divided by letters below, and some paragraphs in each section. Most of these paragraphs should be indented so that they align with the text after each section and not the section number. Will try to clarify with a small code.

I do not have the ability to provide a minimal example, will do so later though

a)   Some section title inserted here with some custom gibberish

How the rest of the paragraph looks with no ident, also a problem 
with seveleral lines aswell

Here is another small part that is not supposed to be indented  

Here is how I want it to look

a)   Some section title inserted here with some custom gibberish

     How the rest of the paragraph looks with no ident, also a problem 
     with seveleral lines aswell

Here is another small part that is not supposed to be indented  

So yeah, I think I can do it with \hspace*{5mm}. But this only works for single lines. Any suggestions?


Edit: MWE

\documentclass[10pt,a4paper]{article}
\usepackage[hmargin=3cm,vmargin=3.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[norsk]{babel}

\usepackage{enumitem}
\usepackage{titletoc}
\usepackage{booktabs}
\usepackage{relsize}
\usepackage{array}
\usepackage[hidelinks]{hyperref}
\usepackage[dvipsnames*,svgnames]{xcolor}
\usepackage{mathtools}

\usepackage{fixltx2e}
\usepackage{lmodern}

\newcommand{\oppgave}[2]{\section*{Oppgave #1 {\normalfont\normalsize (#2 poeng)}
\addcontentsline{toc}{section}{Oppgave #1}}}

\newcommand{\del}[1]{\paragraph*{#1)
\addcontentsline{toc}{subsection}{#1)}}}

\newlist{deloppg}{enumerate}{1}
\setlist[deloppg]{label=\arabic*),leftmargin=1.40cm,itemsep=5pt}

\begin{document}

\tableofcontents

\newpage

\section*{Fasitsvar til regneoppgaver}
\addcontentsline{toc}{section}{Fasitsvar til regneoppgaver}

\newpage

\noindent
\phantomsection
\addcontentsline{toc}{section}{{\color{red}\Large{Del 1}}}
\fcolorbox{black}{LightSteelBlue}{\parbox[t][1.25cm][c]{\textwidth}{\begin{center}\textbf{Del 1 \\Uten hjelpemiddler}\end{center}}}

\oppgave{1}{18}

\del{a} \label{1a}
 Vis at den deriverte til funksjonen $O(x) = \dfrac{500}{x} + 8x^2 $ er
 %
 \begin{align*}
 O'(x) = \frac{ \, -500 + 16x^3 \, }{x^2}
 \end{align*}
%
\del{b} Deriver funksjonene \\
\begin{deloppg}
\item  $ f(x) = 3  \ln(2x)       $ 
\item  $ g(x) = 3x \cdot e^{x^2} $ \aa 
\end{deloppg}
%
\vspace{5mm}
%
\del{c} Vi har gitt polynomfunksjonen $f(x)=x^3 - 3x^2 - 13x + 15$
\begin{deloppg}
\item Vis at $f(1)=0$. Bruk polynomdivisjon til å faktorisere $f(x)$  i førstegradsfaktorer
\item Løs ulikheten $f(x)\leq 0$
\end{deloppg} 
%
\vspace{5mm}
%
\del{d}
Mengden av lava som spruter ut per time ved et vulkanutbrudd kan 
tilnærmet beskrives ved et funksjonsuttrykk $f(x)$. Funksjonsverdiene 
er målt i tonn, og $t$ er antall timer etter begynnelsen av utbruddet. \\
\\
Du får vite at: $f(0)=300, \qquad f'(10)=0 \qquad \textnormal{og} \qquad         f''(10) = -10$\\
\\
 Hva kan du si om vulkanutbruddet på grunnlag av disse opplysningene? 

\end{document}}

I felt I had to include this much of my document to show of where the mistake happens. Was a lot of work finding the packages and such. My preamble only includes 4 packs each with a common theme. So I had to extract all the packages needed to make this page work. The problem is in the last section. Where I want the text to be aligned with the rest. Will try Werner's suggestion =)

share|improve this question
add comment

3 Answers

I would use the adjustwidth environment from the changepage package:

\begin{adjustwidth}{<left margin>}{right margin>}
...
\end{adjustwidth}

The entire contents of adjustwidth is indented from the left margin by <left margin> and from the right margin by <right margin>. Here's a minimal example:

\documentclass{article}
\usepackage{changepage}% http://ctan.org/pkg/changepage
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\section{Some section title inserted here with some custom gibberish}
\begin{adjustwidth}{2.5em}{0pt}
\lipsum[1]
\end{adjustwidth}
\lipsum[2-5]
\end{document}

Adjustwidth of first paragraph

The standard article document class indents the section title by 2.5em.


Edit: After seeing your minimal working example (MWE), I would suggest using the enumitem package to provide the appropriate margin alignment in your "problem" set. Below is a revised version of your MWE with the correct redefinition.

\documentclass[10pt,a4paper]{article}
\usepackage[hmargin=3cm,vmargin=3.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[norsk]{babel}
\usepackage{amsmath}

\usepackage{enumitem}
\usepackage[hidelinks]{hyperref}
\usepackage[dvipsnames*,svgnames]{xcolor}

\newcommand{\oppgave}[2]{\section*{Oppgave #1 {\normalfont\normalsize (#2 poeng)}
\addcontentsline{toc}{section}{Oppgave #1}}}

\newcommand{\del}[1]{%
  \item \addcontentsline{toc}{subsection}{#1)}
}

\newlist{deloppg}{enumerate}{2}
\setlist[deloppg]{label=\arabic*),leftmargin=*,itemsep=5pt}

\begin{document}

\tableofcontents

\newpage

\section*{Fasitsvar til regneoppgaver}
\addcontentsline{toc}{section}{Fasitsvar til regneoppgaver}

\newpage

\noindent
\phantomsection
\addcontentsline{toc}{section}{{\color{red}\Large{Del 1}}}
\fcolorbox{black}{LightSteelBlue}{%
  \parbox[t][1.25cm][c]{\textwidth}{%
    \begin{center}
      \textbf{Del 1 \\Uten hjelpemiddler}
    \end{center}%
  }%
}

\oppgave{1}{18}

\begin{enumerate}[leftmargin=*,labelsep=2em,label=\alph*)]
\del{a} \label{1a}
  Vis at den deriverte til funksjonen $O(x) = \dfrac{500}{x} + 8x^2 $ er
  %
  \begin{align*}
    O'(x) = \frac{ -500 + 16x^3 }{x^2}
  \end{align*}
  %
\del{b} Deriver funksjonene \\
\begin{deloppg}
  \item  $ f(x) = 3  \ln(2x)       $ 
  \item  $ g(x) = 3x \cdot e^{x^2} $ \aa 
\end{deloppg}
%
\vspace{5mm}
%
\del{c} Vi har gitt polynomfunksjonen $f(x)=x^3 - 3x^2 - 13x + 15$
\begin{deloppg}
  \item Vis at $f(1)=0$. Bruk polynomdivisjon til å faktorisere $f(x)$  i førstegradsfaktorer
  \item Løs ulikheten $f(x)\leq 0$
\end{deloppg} 
%
\vspace{5mm}
%
\del{d}
  Mengden av lava som spruter ut per time ved et vulkanutbrudd kan 
  tilnærmet beskrives ved et funksjonsuttrykk $f(x)$. Funksjonsverdiene 
  er målt i tonn, og $t$ er antall timer etter begynnelsen av utbruddet. \\
  \\
  Du får vite at: $f(0)=300, \qquad f'(10)=0 \qquad \textnormal{og} \qquad         f''(10) = -10$\\
  \\
  Hva kan du si om vulkanutbruddet på grunnlag av disse opplysningene? 
\end{enumerate}
\end{document}

Enumitem defintion for problems

Looking at your code there could be some improvements made. However, since the MWE might only cover a portion of what you're after, I merely tried to make things work the way you want them to.

share|improve this answer
    
Thanks this almost works. Problem is that if you look at my code. I basically have to do it like this \del{a} \begin{adjustwidth}{2.5em}{0pt} \lipsum[1] \end{adjustwidth} And the adjustwidth starts a new line. Which is not desirable. Any way to stop the enviroment from starting a new line? –  N3buchadnezzar Oct 9 '11 at 0:11
    
@N3buchadnezzar: I've added an edit to my answer. From looking at your MWE, it seems like an enumitem approach here would be better, rather than using the adjustwidth environment from changepage. I've updated your code with some suggestions and hope this meets your "indentation needs." –  Werner Oct 9 '11 at 1:20
    
@Werner: Just out of curiosity, what language is it you use for edit 1? Could it be Nederlands or Norsk perhaps? –  Tom Bombadil Oct 9 '11 at 1:59
    
@TomBombadil: That is from the OP's original MWE. Using Google Translate, it detects Norwegian. "Nederlands" (or Dutch, rather), looks very much like a mixture of Afrikaans and German (perhaps more like the former) to someone who doesn't know it. –  Werner Oct 9 '11 at 2:10
    
Thanks Werner , I think that will do it =) What sort of improvements were you talkinb about? I would be very interested in hearing about them. This is the first page of an norwegian exam, for students in the age 17-18. Also the language is norwegian, much closer to german, and dutch than Afrikaans. I can sort of read, netherlandic, some german, sweedish and danish. Since they are so similar –  N3buchadnezzar Oct 9 '11 at 10:04
show 3 more comments

You could use the ìtemize environment in an unusual way:

\documentclass[parskip]{scrartcl}
\usepackage[margin=50mm]{geometry}

\begin{document}

\begin{itemize}
    \item[a)] Some section title inserted here with some custom gibberish

How the rest of the paragraph looks with no ident, also a problem 
with seveleral lines aswell
\end{itemize}
Here is another smal part that is not supposed to be inlined. Here is another smal part that is not supposed to be inlined. Here is another smal part that is not supposed to be inlined. 
\begin{itemize}
    \item[b)] Some section title inserted here with some custom gibberish

How the rest of the paragraph looks with no ident, also a problem 
with seveleral lines aswell
\end{itemize}

\end{document}

enter image description here

share|improve this answer
add comment
  • You can put the paragraph into a {minipage} and use calc for calcualting

    \usepackage{calc}
    ...
    a)   Text
    
    \hspace*{\fill}\begin{minipage}{\texwidth-5mm}
        Content
    \end{minipage}
    

    If you prefer you could use a \parbox instead

  • use a tabular with two cols

  • use a list environment

  • if using KOMA-Script you can use the addmargin-environment

maybe there are serval more ways but it would be good to have an example …

share|improve this answer
3  
minipage, \parbox, and most tabular environments will inhibit page breaks within the paragraph. –  lockstep Oct 8 '11 at 22:57
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.