Historique des modifications [retour]
cliquez ici pour masquer/afficher la révision 2

25 Mar '18, 16:22

touhami's gravatar image

touhami
9.9k410

Voici une idée basée sur l'utilisation de la bibliothèque `magazine` de *tcolorbox* \documentclass{article} \usepackage{lmodern} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{multicol} \usepackage[most]{tcolorbox} \usepackage{mwe} \newcounter{mtctr} \newcommand{\mtdisplay}{% \boxarraygetsize{\mtsize}% \setcounter{mtctr}{0}% \loop \stepcounter{mtctr}% \tcbitem\consumeboxarray{\themtctr} \ifnum\value{mtctr}<\mtsize \repeat} \newcommand{\mtdim}{% \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\textheight-1cm\relax} \newenvironment{mttwocols}{% \ifdim\dimexpr\pagegoal-\pagetotal-6\baselineskip\relax>0pt\else\newpage\null\vskip-\baselineskip\fi \begin{tcolorbox}[% breakable, blanker, width=.43\textwidth, break at=\mtdim, reset box array, store to box array]}{% \end{tcolorbox} \tcboxeditemize[% blanker, sharp corners, halign=center, raster columns=2, raster valign=top]{breakable}% \mtdisplay \endtcboxeditemize} \begin{document} \section{Foo} \lipsum[1] \begin{mttwocols} \lipsum[1-20] \end{mttwocols} \end{document} Pour aller plus loin loin. **Remarques** il faut compiler deux fois et il faut supprimer le fichier `.aux` en cas des changements dans `mttwocols`. **Limitation** `mttwocols` à utiliser une fois par fichier, mais ce n'est pas difficile d'adapter le code pour l'utilisation multiple, je vais essayer d'ajouter ce qu'il faut prochainement. \documentclass{article} \usepackage{lmodern} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{multicol} \usepackage[most]{tcolorbox} \newcounter{mtctr} \newcommand{\mtdisplay}{% \boxarraygetsize{\mtsize}% \setcounter{mtctr}{0}% \loop \stepcounter{mtctr}% \tcbitem\consumeboxarray{\themtctr} \ifnum\value{mtctr}<\mtsize \repeat} \AtBeginDocument{ \providecommand{\mtdim}{% \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\textheight-1cm\relax}} \makeatletter \newcommand{\mtsetdim}{% \renewcommand{\mtdim}{% \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\pagegoal-\pagetotal-1cm\relax} \boxarraygetsize{\mtsize} \global\let\mtsize\mtsize \boxarraygetbox{\mtbox}{\mtsize} \ifnum\mtsize>2 \setcounter{mtctr}{3} \loop \ifnum\value{mtctr}<\numexpr\mtsize-1\relax \xdef\mtdim{\mtdim/ \the\dimexpr\textheight-1cm\relax} \stepcounter{mtctr} \repeat \ifodd\value{mtctr} \xdef\mtht{\the\dimexpr.5\textheight+.5\ht\mtbox+\baselineskip\relax} \else \xdef\mtht{\the\dimexpr\textheight-1cm\relax/\the\dimexpr.5\ht\mtbox+\baselineskip\relax} \fi \xdef\mtdim{\mtdim/ \mtht} \fi \immediate\write\@mainaux{\xdef\string\mtdim{\mtdim}} } \makeatother \newenvironment{mttwocols}{% \ifdim\dimexpr\pagegoal-\pagetotal-6\baselineskip\relax>0pt\else\newpage\null\vskip-\baselineskip\fi \begin{tcolorbox}[% breakable, blanker, width=.43\textwidth, break at=\mtdim, reset box array, store to box array]}{% \end{tcolorbox} \mtsetdim \tcboxeditemize[% blanker, sharp corners, halign=center, raster columns=2, raster valign=top]{breakable}% \mtdisplay \endtcboxeditemize} \usepackage{mwe} \begin{document} \section{Foo} \lipsum[1] \begin{mttwocols} \lipsum[1-20] \end{mttwocols} \end{document}\end{document}
cliquez ici pour masquer/afficher la révision 1

24 Mar '18, 01:24

touhami's gravatar image

touhami
9.9k410

Voici une idée basée sur l'utilisation de la bibliothèque `magazine` de *tcolorbox* \documentclass{article} \usepackage{lmodern} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{multicol} \usepackage[most]{tcolorbox} \usepackage{mwe} \newcounter{mtctr} \newcommand{\mtdisplay}{% \boxarraygetsize{\mtsize}% \setcounter{mtctr}{0}% \loop \stepcounter{mtctr}% \tcbitem\consumeboxarray{\themtctr} \ifnum\value{mtctr}<\mtsize \repeat} \newcommand{\mtdim}{% \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\textheight-1cm\relax} \newenvironment{mttwocols}{% \ifdim\dimexpr\pagegoal-\pagetotal-6\baselineskip\relax>0pt\else\newpage\null\vskip-\baselineskip\fi \begin{tcolorbox}[% breakable, blanker, width=.43\textwidth, break at=\mtdim, reset box array, store to box array]}{% \end{tcolorbox} \tcboxeditemize[% blanker, sharp corners, halign=center, raster columns=2, raster valign=top]{breakable}% \mtdisplay \endtcboxeditemize} \begin{document} \section{Foo} \lipsum[1] \begin{mttwocols} \lipsum[1-20] \end{mttwocols} \end{document} Pour aller plus loin \documentclass{article} \usepackage{lmodern} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{multicol} \usepackage[most]{tcolorbox} \newcounter{mtctr} \newcommand{\mtdisplay}{% \boxarraygetsize{\mtsize}% \setcounter{mtctr}{0}% \loop \stepcounter{mtctr}% \tcbitem\consumeboxarray{\themtctr} \ifnum\value{mtctr}<\mtsize \repeat} \AtBeginDocument{ \providecommand{\mtdim}{% \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\textheight-1cm\relax}} \makeatletter \newcommand{\mtsetdim}{% \renewcommand{\mtdim}{% \the\dimexpr\pagegoal-\pagetotal-1cm\relax/ \the\dimexpr\pagegoal-\pagetotal-1cm\relax} \boxarraygetsize{\mtsize} \global\let\mtsize\mtsize \boxarraygetbox{\mtbox}{\mtsize} \ifnum\mtsize>2 \setcounter{mtctr}{3} \loop \ifnum\value{mtctr}<\numexpr\mtsize-1\relax \xdef\mtdim{\mtdim/ \the\dimexpr\textheight-1cm\relax} \stepcounter{mtctr} \repeat \ifodd\value{mtctr} \xdef\mtht{\the\dimexpr.5\textheight+.5\ht\mtbox+\baselineskip\relax} \else \xdef\mtht{\the\dimexpr\textheight-1cm\relax/\the\dimexpr.5\ht\mtbox+\baselineskip\relax} \fi \xdef\mtdim{\mtdim/ \mtht} \fi \immediate\write\@mainaux{\xdef\string\mtdim{\mtdim}} } \makeatother \newenvironment{mttwocols}{% \ifdim\dimexpr\pagegoal-\pagetotal-6\baselineskip\relax>0pt\else\newpage\null\vskip-\baselineskip\fi \begin{tcolorbox}[% breakable, blanker, width=.43\textwidth, break at=\mtdim, reset box array, store to box array]}{% \end{tcolorbox} \mtsetdim \tcboxeditemize[% blanker, sharp corners, halign=center, raster columns=2, raster valign=top]{breakable}% \mtdisplay \endtcboxeditemize} \usepackage{mwe} \begin{document} \section{Foo} \lipsum[1] \begin{mttwocols} \lipsum[1-20] \end{mttwocols} \end{document}

C'est votre première visite ici ? Consultez la FAQ !

×