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.

As I did not get an answer I was fully satisfied with in my last thread, although there were many great suggestions. I will therefore try to rephrase my question here. I also have some new inputs, suggestions and ideas, and I did not want to clutter the last thread with endless edits.

So here is a minimal example of my document

\documentclass[10pt,a4paper]{article}
\usepackage{microtype}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[utf8]{inputenc}
\usepackage[norsk]{babel}
\usepackage{enumitem}
\title{Fy 1001 - Mekanisk Fysikk \\ Øving 8}
\usepackage{changepage}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum

\newcounter{opg}[section]
\renewcommand{\theopg}{\arabic{opg}}
\newcommand{\opg}[1]{\stepcounter{opg} \subsubsection*{Oppgave \theopg #1}     \vspace*{2.25mm}}
\setcounter{opg}{0}

\newcounter{navn}[opg]
\renewcommand{\thenavn}{\alph{navn}}
\newcommand{\navn}{\stepcounter{navn}\paragraph*{\thenavn)}}
\setcounter{navn}{0}

\author{Øistein Søvik}

\date{\today}

\begin{document}
\maketitle

\begin{enumerate}[leftmargin=*,labelsep=1.25em,label=\bfseries\alph*)]
\item Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og     masse $m$, om en akse normalt på stanga
gjennom stangas ene ende.
\end{enumerate}

\opg{: Kjerrehjul}
\navn Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og     masse $m$, om en akse normalt på stanga
gjennom stangas ene ende.

\lipsum[2-3]

\navn Bestem deretter treghetsmomentet $I_k$ for et kjerrehjul med $N$ eiker     (spiler), hver med masse $m$ og lengde
$R$, og der selve hjulet (felgen) har masse $M$. Du kan betrakte felgen som     en tynn ring med radius $R$.
\navn Hva blir kjerrehjulets totale kinetiske energi K dersom det sitter på     ei kjerre som kjører med hastighet
$V$ ? Vi antar ren rulling for kjerrehjulet.\\

opg{: Treghetsmoment for diverse stive legemer} 

Bestem treghetsmomentet $I_0$ om en akse gjennom tyngdepunktet/massesenteret til
\navn ei tynn stang med lengde $L$ og masse $M$. (Akse normalt på stanga.)
\navn et tynt kuleskall med radius $R$ og masse $M$. (Tips: $\sin^3 x =     \frac{3}{4} \sin x - \frac{1}{4} \sin 3x$.)
\navn ei kompakt kule med radius $R$ og masse $M$. (Tips: Kompakt kule = sum     av tynne kuleskall.)\\
\\
\opg{: Atwoods maskin med tung skive som trinse}

\navn 

\end{document}

At the top I included a solution to my problem that does not work. What I am trying to do is almost what this enumerate enviroment does.

I am trying to make questions starting with a letter, and then have some text. Directly afterwards inlined. As the document shows, enumitem does this. However

  1. It aligns everything a tad too much to the right. It should be aligned as the first item.

  2. It is somewhat tiresome / complicated to use for each question

  3. It does not reset after each bigger question.

Now ultimately, I want to define some command or environment that inlines everything inside this command and keeps track of the numbering.

For an example

\mycommand{ Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og     
masse $m$, om en akse normalt på stanga gjennom stangas ene ende. }

should produce

a)   Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og     
     masse $m$, om en akse normalt på stanga gjennom stangas ene ende. 

or

\mycommand{ \item Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og     
       masse $m$, om en akse normalt på stanga gjennom stangas ene ende. }

should produce

a)   Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og     
     masse $m$, om en akse normalt på stanga gjennom stangas ene ende. 

Or enviroment for that sake.

\begin{myenv}
Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og     
masse $m$, om en akse normalt på stanga gjennom stangas ene ende.
\end{myenv}

a)   Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og     
     masse $m$, om en akse normalt på stanga gjennom stangas ene ende. 

So yeah... Looking for an easy way to make a new command. Inlining everything inside of the command. And putting an counting letter at the start. That resets after every \opg.

So everything works as it is. Except that the text after \navn is not horizontally alligned.


EDIT:

Now everything works, except that the first \NR is not alligned. Anyone know why? An automatical way to fix it? Going to use this code quite a lot, so would be good for an automagical fix. At the moment.

Someother problems I am having with this code is the spacing. Right now the spacing varies from wheter the text inside \NR is spaning over one line or several lines. A quick and dirty fix would be much obliged. Also adding \\ after the \NR does not produce any spacing.

\documentclass[10pt,a4paper]{article}
\usepackage{microtype}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[utf8]{inputenc}
\usepackage[norsk]{babel}
\usepackage{enumitem}
\title{Fy 1001 - Mekanisk Fysikk \\ Øving 8}
\usepackage{changepage}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{calc}

\newcounter{opg}[section]
\renewcommand{\theopg}{\arabic{opg}}
\newcommand{\opg}[1]{\stepcounter{opg} \subsubsection*{Oppgave \theopg #1}     \vspace*{2.25mm}}
\setcounter{opg}{0}

\newcounter{navn}[opg]
\renewcommand{\thenavn}{\alph{navn}}
\newcommand{\navn}{\stepcounter{navn}\paragraph*{\thenavn)}}
\setcounter{navn}{0}

\newcommand{\NR}[1]
{
\hspace*{-6.1mm} \noindent \begin{minipage}[t]{0.055 \textwidth}
\navn \hspace{0pt}
\end{minipage}
\begin{minipage}[t]{\textwidth}
#1
\end{minipage}
}

\author{Øistein Søvik}

\date{\today}

\begin{document}
\maketitle

\opg{: Kjerrehjul} 
%
\NR{Bestem treghetsmomentet $I_s$ for ei tynn stang med lengde $R$ og masse     $m$, om en akse normalt på stanga
gjennom stangas ene ende.}

\NR{Bestem deretter treghetsmomentet $I_k$ for et kjerrehjul med $N$ eiker     (spiler), hver med masse $m$ og lengde
$R$, og der selve hjulet (felgen) har masse $M$. Du kan betrakte felgen som     en tynn ring med radius $R$.}

\NR{Hva blir kjerrehjulets totale kinetiske energi K dersom det sitter på ei     kjerre som kjører med hastighet
$V$ ? Vi antar ren rulling for kjerrehjulet}\\

\opg{: Treghetsmoment for diverse stive legemer} 

Bestem treghetsmomentet $I_0$ om en akse gjennom tyngdepunktet/massesenteret til     \\

\NR{ei tynn stang med lengde $L$ og masse $M$. (Akse normalt på stanga.)}\\

\NR{et tynt kuleskall med radius $R$ og masse $M$. (Tips: $\sin^3 x =     \frac{3}{4} \sin x - \frac{1}{4} \sin 3x$.)}\\

\NR{ei kompakt kule med radius $R$ og masse $M$. (Tips: Kompakt kule = sum av     tynne kuleskall.} \\
\end{document}
share|improve this question
6  
It might be a good idea to avoid controversial naming conventions in your commands and environments, such as \slut and \begin{puke}. People on this site generally adhere to the rule, 'if you wouldn't say it in front of co-workers or your boss, don't say it here'. –  cmhughes Oct 18 '11 at 19:38
    
Thanks... I was just so sick and tired of the problem. Thanks to an earlier advice I was aaaalmost able to solve my problem. Now only my first part, is not aligned. Anyone know why? Ckeck my edit –  N3buchadnezzar Oct 18 '11 at 21:36
add comment

1 Answer 1

The code is rather lengthy. Save this code as goodlists.sty.

\ProvidesPackage{goodlists}
\makeatletter
\newtoks\@enLab  %\newtoks\@enfont
\def\@enQmark{?}
\def\@enLabel#1#2{%
  \edef\@enThe{\noexpand#1{\@enumctr}}%
  \@enLab\expandafter{\the\@enLab\csname the\@enumctr\endcsname}%
  \@enloop}

%% Hack to define a space 
\def\@enSpace{\afterassignment\@enSp@ce\let\@tempa= }
\def\@enSp@ce{\@enLab\expandafter{\the\@enLab\space}\@enloop}
\def\@enGroup#1{\@enLab\expandafter{\the\@enLab{#1}}\@enloop}
\def\@enOther#1{\@enLab\expandafter{\the\@enLab#1}\@enloop}
\def\@enloop{\futurelet\@entemp\@enloop@}

\def\@enloop@{%
  \ifx A\@entemp         \def\@tempa{\@enLabel\Alph  }\else
  \ifx a\@entemp         \def\@tempa{\@enLabel\alph  }\else
  \ifx i\@entemp         \def\@tempa{\@enLabel\roman }\else
  \ifx I\@entemp         \def\@tempa{\@enLabel\Roman }\else
  \ifx 1\@entemp         \def\@tempa{\@enLabel\arabic}\else
  \ifx \@sptoken\@entemp \let\@tempa\@enSpace         \else
  \ifx \bgroup\@entemp   \let\@tempa\@enGroup         \else
  \ifx \@enum@\@entemp   \let\@tempa\@gobble          \else
                         \let\@tempa\@enOther
             \fi\fi\fi\fi\fi\fi\fi\fi
  \@tempa}

\newlength{\@sep} \newlength{\@@sep}

\setlength{\@sep}{.5\baselineskip plus.2\baselineskip
            minus.2\baselineskip}

\setlength{\@@sep}{.1\baselineskip plus.01\baselineskip
            minus.05\baselineskip}

\providecommand{\sfbc}{\rmfamily\upshape}

\providecommand{\sfn}{\rmfamily\upshape}

\def\@enfont{\ifnum \@enumdepth >1\let\@nxt\sfn \else\let\@nxt\sfbc \fi\@nxt}


\def\enumerate{%
   \ifnum \@enumdepth >3 \@toodeep\else
      \advance\@enumdepth \@ne
      \edef\@enumctr{enum\romannumeral\the\@enumdepth}\fi
   \@ifnextchar[{\@@enum@}{\@enum@}}

\def\@@enum@[#1]{%
  \@enLab{}\let\@enThe\@enQmark
  \@enloop#1\@enum@
  \ifx\@enThe\@enQmark\@warning{The counter will not be printed.%
   ^^J\space\@spaces\@spaces\@spaces The label is: \the\@enLab}\fi
  \expandafter\edef\csname label\@enumctr\endcsname{\the\@enLab}%
  \expandafter\let\csname the\@enumctr\endcsname\@enThe
  \csname c@\@enumctr\endcsname7
  \expandafter\settowidth
            \csname leftmargin\romannumeral\@enumdepth\endcsname
            {\the\@enLab\hskip\labelsep}%
  \@enum@}

\def\@enum@{\list{{\@enfont\csname label\@enumctr\endcsname}}%
           {\usecounter{\@enumctr}\def\makelabel##1{\hss\llap{##1}}%
     \ifnum \@enumdepth>1\setlength{\topsep}{\@@sep}\else
           \setlength{\topsep}{\@sep}\fi
     \ifnum \@enumdepth>1\setlength{\itemsep}{0pt plus1pt minus1pt}%
      \else \setlength{\itemsep}{\@@sep}\fi
     %\setlength\leftmargin{\leftMargin}%%%{1.8em}
     \setlength{\parsep}{0pt plus1pt minus1pt}%
     \setlength{\parskip}{0pt plus1pt minus1pt}
                   }}

\def\endenumerate{\par\ifnum \@enumdepth >1\addvspace{\@@sep}\else
           \addvspace{\@sep}\fi \endlist}
\makeatother

Then try it with this minimal, by changing the option after the enumerate, you change the list enumeration i.e., changing \begin{enumerate}[1.)] will give you numbers, changing to [a)], alpha numbering and so on and it indents the way you want :

\documentclass{article}
\usepackage{goodlists}
\begin{document}
\begin{enumerate}[a)]
 \item The enumerate environment starts with an optional
   argument `1.', so that the item counter will be suffixed
   by a period.
 \item You can use `a)' for alphabetical counter and '(i)' for
   roman counter.
  \begin{enumerate}[1)]
    \item Another level of list with alphabetical counter.
    \item One more item before we start another.
    \begin{enumerate}[(i)]
     \item This item has roman numeral counter.
     \item Another one before we close the third level.
    \end{enumerate}
    \item Third item in second level.
  \end{enumerate}
 \item All list items conclude with this step.
 \end{enumerate}
\end{document}
share|improve this answer
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.