Quantcast
Channel: Automatic margin curly braces & text on multiple pages - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by Gonzalo Medina for Automatic margin curly braces & text on multiple pages

$
0
0

Here's an option using tcolorbox instead of mdframed; this version takes care of all three requirements:

  1. Uses braces.
  2. Braces are placed on the outer margin.
  3. The box has a width equal to the \textwidth; the braces are in the margin area.

The code:

\documentclass{scrbook}\usepackage{fontspec,collect,multido,lipsum}\usepackage{changepage}\strictpagecheck\newcounter{extrait}\newcounter{fiche}\usepackage[framemethod=tikz,usetwoside]{mdframed}\usepackage[many]{tcolorbox}\usetikzlibrary{calc,arrows,decorations.pathreplacing}\newtcolorbox{tcbdecor}[1]{  check odd page,  breakable,  colback=white,  boxrule=0pt,  colframe=white,  arc=0pt,  outer arc=0pt,  top=0pt,  bottom=0pt,  enhanced jigsaw,  oversize,  overlay={    \ifoddpage       \draw[decoration=brace,decorate,line width=1pt]         (frame.north east) -- node[rotate=270,above=4pt] {... #1 ...} (frame.south east);    \else      \draw[decoration={brace,mirror},decorate,line width=1pt]         (frame.north west) -- node[rotate=90,above=4pt] {... #1 ...} (frame.south west);    \fi  },}\newcommand\histoire[2]{%  \addtocounter{fiche}{1}%  \definecollection{his\thefiche}%  \begin{tcbdecor}{#1}  \begin{collect*}%    {his\thefiche}{}{}%    {\minisec{Extrait \addtocounter{extrait}{1}\theextrait : #1}}     {}   #2  \end{collect*}%  \end{tcbdecor}%}\begin{document}\chapter{Tests}\histoire{A}{\lipsum[1-3]}\lipsum[4]\histoire{B}{\lipsum[5-7]}\lipsum[8]\histoire{C}{\lipsum[9-16]}\chapter{Restitutions}\multido{\i=0+1}{\thefiche}{\setcounter{fiche}{1}\addtocounter{fiche}{\i}\includecollection{his\thefiche}}\end{document}

The result:

enter image description here

A zoomed-in image showing one of the boxes on an odd numbered page:

enter image description here

A zoomed-in image showing one of the boxes on an even numbered page:

enter image description here

If you want brackets instead, simply change the overlay section to

  overlay={    \ifoddpage       \draw[line width=1pt]         ([xshift=-5pt]frame.north east) -- (frame.north east) -- node[rotate=270,above=4pt] {... #1 ...} (frame.south east) -- ([xshift=-5pt]frame.south east);    \else      \draw[line width=1pt]         ([xshift=5pt]frame.north west) -- (frame.north west) -- node[rotate=90,above=4pt] {... #1 ...} (frame.south west) -- ([xshift=5pt]frame.south west);    \fi  },

With the above example, one now gets

enter image description here

on an odd numbered page, and

enter image description here

on an even numbered one.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>