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.

So I have this user defined function below. This gives me near optimal results. The code is supposed to make numbered subsections. Where the rest of the text is aligned below. Since these subsections usually only span over 1-3 lines, this looks good.

\documentclass[10pt,a4paper]{article}
\usepackage[hmargin=3.5cm,vmargin=2cm]{geometry}
\usepackage{lipsum}
\newcounter{problem}
\setcounter{problem}{0}

\newcounter{navn}[problem]
\renewcommand{\thenavn}{\alph{navn}}
\newcommand{\navn}{  \stepcounter{navn} \hspace{ -0.12cm} \bfseries \thenavn) }
\setcounter{navn}{0}

\newcommand{\NR}[1]
{ \vspace{5mm} \begin{minipage}[t]{0.051 \textwidth}
 \navn \hspace{0pt}
\end{minipage}
\begin{minipage}[t]{0.949\textwidth}
#1 
\end{minipage}
\vspace{-0.3cm}
\addcontentsline{toc}{subsubsection}{\textnormal{ \thenavn })}
}

\newcommand{\UR}[1]
{ \begin{minipage}[t]{0.051 \textwidth}
 \hspace{0pt}
\end{minipage}
\begin{minipage}[t]{0.949\textwidth}
#1
\end{minipage}\vspace*{-0.4cm}
}
\setlength{\parindent}{0in}
\begin{document}
\NR{\lipsum[1]}

{\lipsum[5]}

\UR{\lipsum[2]}

\NR{Hello}

\[ x^2 + 3x + 4 \]

\NR{Problems}

\NR{Problems}

\lipsum[3]
\end{document}    

Now, after compiling this code. One can clearly see that the text beneath the \NR command is coming to close to the actual text. Of course this is caused by the negative spacing inside the command. However this code is needed otherwise the spacing between the \NR command, and following images are far to large. Also the spacing regarding functions increases too much.

One can also see in the code, that the length of the command is set by default.

The spacing in my MWE between c) and e) Is perfect. I know I can use \\ to increase the spacing, but this gets tedious and is against the spirit of Latex.

My question now is how do I properly define the spacing? More specifically:

  • How do I define that the minipages, should always start at the width of the page, with a default indent?

  • How do I properly define the horizontal space before and after the command? (So that it is the same as in the MWE but also fixes the normal text problem)

share|improve this question
    
Is there a reason why a standard enumerate environment does not work for you? If you want to consider that I would use the enumitem package. See what are the differences between using paralist vs enumitem –  Peter Grill Nov 24 '11 at 15:46
    
I also need text between the parts, that is not indented. –  N3buchadnezzar Nov 24 '11 at 15:50
1  
For that you could just end the enumerate and resume it after. Is there something other than indentation that you are trying to accomplish with these minipages? –  Peter Grill Nov 24 '11 at 16:04

2 Answers 2

up vote 3 down vote accepted

If you don't want to use enumitem, here is an improved version of your macros:

\newcounter{navn}[problem]
\renewcommand{\thenavn}{\alph{navn}}
\newcommand{\navn}{\stepcounter{navn}\bfseries\thenavn)}
\setcounter{navn}{0}

\newcommand{\NR}[1]{%
  \par\addvspace{5mm}\noindent\makebox[0.05\textwidth][l]{\navn}%
  \begin{minipage}[t]{0.95\textwidth}
  #1\par\xdef\tpd{\the\prevdepth}
  \addcontentsline{toc}{subsubsection}{\textnormal{ \thenavn })}%
  \end{minipage}\par\prevdepth\tpd
  %\addvspace{0.3cm}
}

\newcommand{\UR}[1]{%
  \noindent\makebox[0.05\textwidth][l]{}% 
  \begin{minipage}[t]{0.95\textwidth}
  #1\par\xdef\tpd{\the\prevdepth}
  \end{minipage}\par\prevdepth\tpd
  %\addvspace{0.3cm}
}

Uncomment the two lines if you want to ensure a minimum spacing after the minipages. For the \prevdepth trick, see How to keep a constant baselineskip when using minipages (or \parboxes)?

share|improve this answer

I would recommend that you use enumerate from the enumitem package. For text that is not to be indented you can end the enumerate and simply use the resume option when you start it up again:

Basic Solution:

\documentclass[10pt,a4paper]{article}
\usepackage[hmargin=3.5cm,vmargin=2cm]{geometry}
\usepackage{enumitem}
\usepackage{lipsum}

\setlength{\parindent}{0in}

\begin{document}
\begin{enumerate}[label=\textbf{\alph*}),labelsep=1.5em]
    \item \lipsum[1]
\end{enumerate}

\lipsum[5]

\lipsum[2]

\begin{enumerate}[resume,label=\textbf{\alph*}),labelsep=1.5em]
    \item Hello
    \[ x^2 + 3x + 4 \]

    \item Problems

    \item Problems
\end{enumerate}

\lipsum[3]
\end{document}    

Updated Solution:

If there is often a need to exit/resume the enumerate environment you could just wrap that into a macro:

\documentclass[10pt,a4paper]{article}
\usepackage[hmargin=3.5cm,vmargin=2cm]{geometry}
\usepackage{enumitem}
\usepackage{lipsum}

\setlength{\parindent}{0in}

\newcommand{\PauseList}[1]{%
    \end{enumerate}
    #1
    \begin{enumerate}[resume,label=\textbf{\alph*}),labelsep=1.5em]
}%

\begin{document}
\begin{enumerate}[label=\textbf{\alph*}),labelsep=1.5em]
    \item \lipsum[1]

    \PauseList{
        \lipsum[5]
    }

    \item Hello
    \[ x^2 + 3x + 4 \]

    \item Problems

    \item Problems
\end{enumerate}

\lipsum[3]
\end{document}    
share|improve this answer
    
Only problem is that there is alot of space not needed to indent. So using the enumerate package would be more tedious... In my eyes. –  N3buchadnezzar Nov 24 '11 at 16:09
    
Ok, then you could simply wrap a macro around that. See updated solution. –  Peter Grill Nov 24 '11 at 16:19
    
Thanks for your comment. Here is an example file of what I am making. This is made using the command above 2shared.com/document/ZMtCAlq2/T1_H10.html. I just feel the minipages are far more flexible. Now could one have sublists like itemize, tables, figures, reseting the list, inside one enumerate list? Otherwise this once again seems tedious. Thanks a ton for your comments though =) –  N3buchadnezzar Nov 24 '11 at 16:37

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.