Problème lors d'une utilisation avec le paquet listing (insertion de code soure dans un questionnaire)

Added by c goutte about 8 years ago

Bonjour à tous - je suis débutant avec latex.
Dans un questionnaire je souhaite avoir l'opinion de candidats sur un bout de code.
Je vous fournis l'exemple suivant (qui est aussi en pj)

L'erreur renvoyée est :

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.44 ...scoring{1}\correctchoice[J]{j}\scoring{2}}

Le segment de code concerné est :

\begin{question}{Q0}
Que vaut var apres ces deux lignes
\begin{lstlisting}
def f():
    print('Lorem')
\end{lstlisting}
%Décommenter et cela fonctionne 
\AMCOpen{lines=2}{\wrongchoice[F]{f}\scoring{0}\wrongchoice[P]{p}\scoring{1}\correctchoice[J]{j}\scoring{2}}
\end{question}

À toute fin utile je joint les contenus du document et de la sortie standard.

%Pour illuster le probleme de nouvelle ligne avec un lsiting python
%Voir ligne 42

\documentclass[a4paper]{article}

\usepackage[utf8x]{inputenc}    
\usepackage[T1]{fontenc}

\usepackage[francais,bloc,completemulti]{automultiplechoice}
\usepackage{listings}

\lstset{language=Python}  

\begin{document}
\noindent{}

\vspace*{.5cm}
\begin{minipage}{.4\linewidth}
\centering\large\bf Test python \end{minipage}
\champnom{\fbox{
                \begin{minipage}{.5\linewidth}
                  Nom et prénom :

                \vspace*{.5cm}\dotfill
                \vspace*{1mm}
                \end{minipage}
                }
            }

\begin{center}\em 
\end{center}
\vspace{1ex}

\begin{question}{Q0}
Que vaut var apres ces deux lignes
\begin{lstlisting}
def f():
    print('Lorem')
\end{lstlisting}
%Décommenter et cela fonctionne 
\AMCOpen{lines=2}{\wrongchoice[F]{f}\scoring{0}\wrongchoice[P]{p}\scoring{1}\correctchoice[J]{j}\scoring{2}}
\end{question}

\end{document}

Log de sortie :

 pdflatex pb_newline.tex 
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./pb_newline.tex
LaTeX2e <2015/10/01> patch level 2
Babel <3.9n> and hyphenation patterns for 4 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def))
(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-global.def))
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def))
(/usr/share/texmf/tex/latex/AMC/automultiplechoice.sty
(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/color.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty)
(/usr/share/texlive/texmf-dist/tex/latex/bophook/bophook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/keyval.tex))))
(/usr/share/texlive/texmf-dist/tex/latex/rotating/rotating.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/graphics.cfg)))
(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/environ/environ.sty
(/usr/share/texlive/texmf-dist/tex/latex/trimspaces/trimspaces.sty))
(/usr/share/texlive/texmf-dist/tex/latex/etex-pkg/etex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.sty
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstmisc.sty)
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.cfg))
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty)
(./pb_newline.aux) (/usr/share/texlive/texmf-dist/tex/latex/ucs/ucsencs.def)
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-0.def)

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.44 ...scoring{1}\correctchoice[J]{j}\scoring{2}}

? ^]

pb_newline.tex (995 Bytes)


Replies (2)

RE: Problème lors d'une utilisation avec le paquet listing (insertion de code soure dans un questionnaire) - Added by Alexis Bienvenüe about 8 years ago

Le fichier que vous avez joint ne produit pas d'erreur… car il n'utilise pas \exemplaire pour générer plusieurs copies.
Le problème vien de l'utilisation de lstlisting qui n'est pas bien supportée par AMC comme cela se produit avec certains environnements du type verbatim : voir Verbatim inside questions.

RE: Problème lors d'une utilisation avec le paquet listing (insertion de code soure dans un questionnaire) - Added by c goutte about 8 years ago

Pauvre de moi.
Je ne savais pas que je pouvais simplement appuyer sur entrée et que la génération du document allait tout de même se faire correctement dans cet exemple.

Merci pour la rapidité, l'indication et la piste :)

(1-2/2)