2

I am starting to convert to LaTeX to do my homework for Math courses. I want to use sectioning to separate questions

\section{5.3}
\subsection{1}
\subsubsection{a}

and look something like this:

I tried to use titlesec to put the section labels in the margin but I can't stack them like I want. Any help?

4
  • 1
    If you're placing numbers as your section "title", then you're better off using an enumeration; for this you should consider the enumitem package.
    – Werner
    Feb 6, 2015 at 6:06
  • Are you interested in manually labelling content the way you're doing? Or is it that the list will not follow each other in some form of sequence (numerically/alphabetically)?
    – Werner
    Feb 6, 2015 at 6:14
  • @Werner Yes I want to be able to skip labels
    – TwiNight
    Feb 6, 2015 at 9:19
  • @TwiNight even if you like this you can always use \addtocounter{CTR}{somme value}
    – touhami
    Feb 6, 2015 at 10:29

1 Answer 1

1

Based on the assumption that you want total manual control over the list items, the following homework environment should suffice:

enter image description here

\documentclass{article}

\newcommand{\newsection}[1]{\gdef\seclab{#1\gdef\seclab{}}}
\newcommand{\newsubsection}[1]{\gdef\subseclab{#1\gdef\subseclab{}}}
\newcommand{\newsubsubsection}[1]{\gdef\subsubseclab{#1\gdef\subsubseclab{}}}

\makeatletter
\newenvironment{homework}[1][1.5em]
  {% \begin{homework}
   \addtolength{\@totalleftmargin}{#1}% Accommodate wide labels
   \renewcommand{\labelitemi}{\textbf{\seclab~\subseclab\subsubseclab}}%
   \begin{itemize}}
  {\end{itemize}}% \end{homework}
\makeatother
\begin{document}

\begin{homework}
  \newsection{5.3}
  \newsubsection{1}
  \newsubsubsection{a}

  \item Solution to question 1a.

    blah blah blah \ldots

  \newsubsubsection{b}

  \item Solution to question 1b.

    blah blah blah \ldots

  \newsubsection{2}
  \newsubsubsection{a}

  \item Solution to question 2a.

    blah blah blah \ldots

  \newsubsubsection{b}

  \item Solution to question 2b.

    blah blah blah \ldots
\end{homework}

\end{document}

The homework environment takes an optional argument that you can use to push the entire list over to the right, in case your section labels become too big and roll over into the left margin (they are right-aligned).

1
  • Have to do some tweaking but get me where I wanted. Thanks
    – TwiNight
    Feb 7, 2015 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.