2

I have a question...

If I have a list like

\begin{enumerate}

\item Objective 1

\item Objective 2

\item Objective 3

\end{enumerate}

And I want to use each item as a subsection for describing each. What do I use? I have been searching a lot and I can't find an answer.

I want after that enumerate environment, to use a label instead of writing all the objective again and describe that objective as a subsection.

Thank you very much for your answers!

Troy
  • 13,741
miklos
  • 21

3 Answers3

2

You can load enumitem and write something like this:

\begin{enumerate}[label=Objective \arabic*., wide=0pt, font=\bfseries]
   \item Description of Objective1
   \item Description of Objective2
   \item Description of Objective3
\end{enumerate}
Bernard
  • 271,350
2

You can use lists: See the answers here for creating a list with custom separator to use in foreach loop (You need it to have the possibility of adding a comma in your sentance)

I will provide a code using @HeikoOberdiek's answer of the above link:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{pgffor}
\usepackage{etoolbox}
\usepackage{etexcmds}
\DeclareListParser*{\forvertlist}{|}

\makeatletter
\newcommand{\vertocomma}[2]{%
  \let#1\@empty
  \forvertlist{\@verttocomma{#1}}{#2}%
}
\newcommand{\@verttocomma}[2]{%
  \edef#1{%
    \ifx#1\@empty
    \else
      \etex@unexpanded\expandafter{#1},%
    \fi
    {\etex@unexpanded{#2}}%
  }%
}
\makeatother

\newcounter{ii}
\vertocomma\mylist{sentenceA|| One big sentence to see if it works with the section and if it breaks lines..|se,nt,en,ce,B| sentenceC | }
\foreach \x in \mylist {%
  \stepcounter{ii}%
  %\typeout{[\meaning\x]}%
  \global\expandafter\let\csname myObj\arabic{ii}\endcsname\x%
}





\usepackage{titlesec}
\titleformat{\section}[display]
{\normalfont\bfseries}
{Item \arabic{section}:\space \csname myObj\arabic{section}\endcsname}{0pt}{}
\begin{document}
\setcounter{ii}{0}
\begin{enumerate}
\foreach \x in \mylist
{\stepcounter{ii}
\item\label{it:\arabic{ii}} \x
}
\end{enumerate}


\section{}

This item is the \ref{it:\arabic{section}} item and ends with a full-stop.\csname myObj1\endcsname

\section{}

The item \ref{it:2} is a sentence with many commas


\end{document}

You can chose the way to make the list or copy and use this one.

The result is:

enter image description here

(Edit: You can use 'nameref' too inside your subsections (I think it will work) if you don't like the titleformat command.)

Good Luck (The sections can be formated as you wish or be empty like mine)

koleygr
  • 20,105
  • I found that it is a much easier way in the link I provided with the comand of cptforeah from package catoptions... Check that too... I will edit my answer according to this command – koleygr Jul 05 '17 at 07:58
  • Thanks, this is a good choice, but the nameref package does the specific task I needed. – miklos Jul 06 '17 at 20:21
1

Are you trying to make a table of contents as in the minimal working example (MWE) below?

Or may be a mini table of contents? (also in the MWE)

Otherwise, you can use the nameref package (of course, also in the MWE):

mwe

\documentclass{article}
\usepackage{lipsum} % for dummy text
\usepackage{minitoc}
\usepackage{nameref} % Note: Do not load it before minitoc ! 
\begin{document}

\dosecttoc

\tableofcontents

\section{Introduction} Bla bla bla ...
\section{Objectives}

\begin{enumerate}
\item \nameref{obj1}
\item \nameref{obj2}
\item \nameref{obj3}
\end{enumerate}

\renewcommand\stctitle{} %no title for minitoc
\nostcpagenumbers % no page numbers
\secttoc[c]


\subsection{The first funny objective}\label{obj1}\lipsum[1] 
\subsection{The hard and really complex objective}\label{obj2}\lipsum[2] 
\subsection{The last and final objective}\label{obj3}\lipsum[3] 

\end{document}
Fran
  • 80,769