0

My question is probably not very clear! I am writing a summary paper on students. Each student has a section. In the section I specify its qualities and results and at the end I put a noted opinion

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode


\documentclass[11pt]{article}  

\usepackage[utf8]{inputenc}

\usepackage{lipsum}

\newcommand{\Avis}[1]{
\textbf{Avis=#1}
\addcontentsline{toc}{subsection}{Avis=#1}
}

\begin{document}

\tableofcontents
\clearpage

\section{Nom-Prenom1}

\lipsum[2]

\Avis{5}

\section{Nom-Prenom2}

\lipsum[3]

\Avis{8}


\section{Nom-Prenom3}

\lipsum[5]

\Avis{10}


\end{document}

I would like that in the summary we find on the same line

Last name1 first name1: Opinion=8------------------------page no.

Last name2 first name2: Opinion=5------------------------page no.

enter image description here

7
  • The sectioning commands of mist classes have an optional argument. So you could use: \section[Last Name1 First Name1: Opinion=8]{Last Name1 First Name1} If your class also provides an optional argument (or even two) is unclear, because you've not shown the class.
    – cabohah
    Commented Apr 14 at 15:31
  • Related: tex.stackexchange.com/q/6862/277964
    – cabohah
    Commented Apr 14 at 15:36
  • I use an article class. I don't want to use the section option, for that I would have to go back, I would prefer to write my opinion at the end of my comments and add it to the summary. For the moment I "cheat" I put the opinion as the title of the subsection and it appears in the summary.
    – rpapa
    Commented Apr 14 at 16:23
  • 1
    Please add all relevant information to the question and make the example compile without error. You are ling enough here to know, how to ask good questions. However, I don't see a reason, why not adding the opinion at the beginning instead at the end of the section,
    – cabohah
    Commented Apr 14 at 16:43
  • There are a number of ways to do this. Easiest would be to create a new file like toc or lof and use \addcontentsline to record the data and \@starttoc in the summary. section. You will also need a \l@summary or something similar to format each entry. (see \@dottedtocline). Commented Apr 14 at 17:11

1 Answer 1

2

Here's a way to do it. A few comments:

  • one idea was defining a new environment; however using it is clumsy AND for some reason it didn't like an argument, like #3, in its end-part
  • so I introduced \newcommand\student[4]{% last, first, avis, comments ...
  • it incorporates cabohah's idea about the sections
  • in the documents body I show some ways to use it, i.e. by adjusting code formatting
  • packages: tikz is probably on your system, while simpsons might be missing (just comment out, if you don't want these)
  • basically you write your normal LaTeX code as parameter #4
  • if you miss the dots in the TOC, that's no big deal to introduce

result

\documentclass[11pt]{article}  
%\usepackage[utf8]{inputenc}
\usepackage{lipsum}

% ~~~ simpsonizing ... ~~~
\usepackage{tikz}       % is probably on your system
\usepackage{simpsons}   % perhaps needs to be installed


% ~~~~~~~~~~~~~~~~~~~~~~~~~~
\newcommand\student[4]{% last, first, avis, comments
\section[#1, #2: Avis=\ #3]{#1, #2}%
#4%

\textbf{Avis: #3}%
}

% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
 \tableofcontents
 \clearpage

 \student{Hitchcock}{Alfred}{10}{
Master or horriffic horror secenes. 
 }
 
 \student{Einstein}{Albert}{3}{
    \lipsum[5-6]
 }
 
 % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 \student   {Simpson}
            {Bart}
            {0}
    {
    Do I really need to say more?
    
    \vspace{20pt}
    \begin{tikzpicture}
        \node[draw=red] {You s**k!};
    \end{tikzpicture}
    \Bart
 }

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .