1

Some times I need to enclose a list of questions in a minipage to put a picture on the right. When the minipage starts with a list there is an indent problem, when there is somme text before it works fine. How to avoid this problem.

The third instance is the one I want to avoid: I want it looks like the first.

enter image description here

\documentclass[10pt,a4paper,french]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\usepackage{tikz,xparse,calc}

% Redefinir les etiquettes des listes
\usepackage[flushleft,alwaysadjust]{paralist}
    %[flushleft,alwaysadjust] les options annulent le décalage vers la droite

% Défini les étiquettes des listes par défaut.
\setdefaultenum{\bf 1.}{a)}{\it i.)}{}

% Défini les étiquettes des itemize par défaut.
\setdefaultitem{$\bullet$}{$\circ$}{}{}

\setdefaultleftmargin{1.5em}{1.5em}{}{}{}{}

\newcounter{ex}

\NewDocumentEnvironment{ListExos}{sO{0}}{%
    \setcounter{ex}{#2}
    \begin{list}
        % défini la forme de l'étiquette
        {\stepcounter{ex}{%
        \tikz[anchor=base, baseline]
            \node[RndBox,minimum width=20pt] {\theex} ;}}
        % défini les longueurs
        {\setlength{\labelwidth}{0pt}
         \setlength{\leftmargin}{0pt}
         \setlength{\itemindent}{0pt}
         \IfBooleanTF{#1}{\setlength{\itemsep}{0pt}}{}
         %\setlength{\parsep}{2pt} % Espace entre deux paragraphes dans une liste
         %\setlength{\itemsep}{.5em} ne pas toucher car cela
         %\setlength{\labelsep}{0pt} influence les sous liste
         }%
        %\vspace{0.5em}
    }
    {\end{list}}

\tikzset{RndBox/.style args={#1 and #2}{%
    thick,
    fill=#1,
    inner sep=0pt,
    draw=#2,
    text=#2,
    rounded corners=2pt,
    minimum width=.6cm,
    minimum height=1.25em,
    text depth = 0ex,
    font = \bfseries\sffamily
    },
    RndBox/.default={gray!25 and black}
}

\begin{document}

\begin{ListExos}
\item \begin{compactenum}
\item bla
\item bla
\end{compactenum}
\end{ListExos}

\bigskip

\begin{ListExos}
\item \hspace{-20pt}%
\begin{minipage}[t]{\linewidth-4cm}
\raggedrigth% ne pas commencer par une liste directement
\hspace{20pt} Some text before the first question.

\begin{compactenum}
\item bla
\item bla
\end{compactenum}
\end{minipage}
\end{ListExos}

\bigskip

How make it work without some text before the first question.

\begin{ListExos}
\item \hspace{-20pt}%
\begin{minipage}[t]{\linewidth-4cm}
\raggedrigth% ne pas commencer par une liste directement
\hspace{20pt}\begin{compactenum}
\item bla
\item bla
\end{compactenum}
\end{minipage}
\end{ListExos}


\verb+\setlength\itemindent{-20pt}+ doesn't for several lines

\bigskip

\begin{ListExos}
\item \begin{minipage}[t]{5cm}
\raggedright% ne pas commencer par une liste directement

\begin{compactenum}

\item Reproduire une figure du même type que celle ci-contre.

\setlength\itemindent{-20pt}

\item Contruire deux points $B$ et $C$ tels que C soit inscrit dans le triangle $ABC$.

Proposer plusieurs solutions.
\end{compactenum}
\end{minipage}
\end{ListExos}

\end{document}
9
  • It is not clear. Of the three instances in the diagram at the top of your question, which of the 3 are "good" and which are "bad"? Commented Apr 14, 2016 at 15:04
  • 1
    @StevenB.Segletes The third instance is the one I want to avoid.
    – Tarass
    Commented Apr 14, 2016 at 15:14
  • Please note that the list spacings are different in minipage environments
    – user31729
    Commented Apr 14, 2016 at 15:30
  • @ChristianHupfer I don't understand.
    – Tarass
    Commented Apr 14, 2016 at 15:49
  • is the indentation on the lines after the first in the multi-line example what you want? do the boxed numbers ever increase to more than one digit, and if so, does the width of the box change? Commented Apr 14, 2016 at 16:28

2 Answers 2

1

There are a number of things I would do differently, but here is a possible work around for your last environment:

\begin{ListExos}
  \item %\hspace{-20pt}%
    \begin{minipage}[t]{\linewidth-4cm}
      %\hspace{20pt}%  
      \raggedright% ne pas commencer par une liste directement
      \begin{compactenum}%%
        \item bla
        \setlength\itemindent{-20pt}
        \item bla
      \end{compactenum}
    \end{minipage}
\end{ListExos}

enter image description here

Part of your problem is using the \hspace{20pt}. You're creating a box which will cause the list environment to add vertical space. Instead, what I've done is reset the \itemindent after the item in your list.

1
  • Doesn't work for several lines case. See my edit.
    – Tarass
    Commented Apr 14, 2016 at 15:46
0

Put the item in the minipage solves the problem.

enter image description here

\documentclass[10pt,a4paper,french]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\usepackage{tikz,xparse,calc}

% Redefinir les etiquettes des listes
\usepackage[flushleft,alwaysadjust]{paralist}
    %[flushleft,alwaysadjust] les options annulent le décalage vers la droite

% Défini les étiquettes des listes par défaut.
\setdefaultenum{\bf 1.}{a)}{\it i.)}{}

% Défini les étiquettes des itemize par défaut.
\setdefaultitem{$\bullet$}{$\circ$}{}{}

\setdefaultleftmargin{1.5em}{1.5em}{}{}{}{}

\newcounter{ex}

\NewDocumentEnvironment{ListExos}{sO{0}}{%
    \setcounter{ex}{#2}
    \begin{list}
        % défini la forme de l'étiquette
        {\stepcounter{ex}{%
        \tikz[anchor=base, baseline]
            \node[RndBox,minimum width=20pt] {\theex} ;}}
        % défini les longueurs
        {\setlength{\labelwidth}{0pt}
         \setlength{\leftmargin}{0pt}
         \setlength{\itemindent}{0pt}
         \IfBooleanTF{#1}{\setlength{\itemsep}{0pt}}{}
         %\setlength{\parsep}{2pt} % Espace entre deux paragraphes dans une liste
         %\setlength{\itemsep}{.5em} ne pas toucher car cela
         %\setlength{\labelsep}{0pt} influence les sous liste
         }%
        %\vspace{0.5em}
    }
    {\end{list}}

\tikzset{RndBox/.style args={#1 and #2}{%
    thick,
    fill=#1,
    inner sep=0pt,
    draw=#2,
    text=#2,
    rounded corners=2pt,
    minimum width=.6cm,
    minimum height=1.25em,
    text depth = 0ex,
    font = \bfseries\sffamily
    },
    RndBox/.default={gray!25 and black}
}

\begin{document}
\begin{ListExos}
\begin{minipage}[t]{5cm}
\raggedright% ne pas commencer par une liste directement
\item \begin{compactenum}

\item Reproduire une figure du même type que celle ci-contre.

\item Contruire deux points $B$ et $C$ tels que C soit inscrit dans le triangle $ABC$.

Proposer plusieurs solutions.
\end{compactenum}
\end{minipage}
\end{ListExos}

\end{document}

You must log in to answer this question.

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