4

I'm building a command to mark long texts & class them in other part of my document (with help of Malipivo). I managed to do it with collect, multido & mdframed packages. The excellent advantage of mdframed is that you can easily handle four possible cutting of a text on several pages: single, first, middle or second part. This is extraordinary for automatic commands.

So, now, I have a problem I don't solve alone :

  1. Following these opportunities, I want to change left lines by curly braces : just old curly braces like in symphonic scores or Diderot's encyclopedia, braces which start from the top of the marked text & coming down… (In truth, I'd use hooks, parens or angle to, like in the Andrew Swann's answer here, and with different levels like in the first Qrrbrbirlbel's answer, but with a more classic brace's style).

Here are two other issues that are less important, but if you find simple solutions… :

  1. How to work in mdframed, tikz option (maybe I don't need tikz), with two side pages ? I'm only using the leftmargin, but I'd rather use the outermargin… Exist a twoside-mode man p.9, but I don't understand how to use.
  2. With mdframed, I work nether in the real page margin, always in the text width. I'd like to put my lines, mark text, braces & other, outside in the real margin without affecting the text in its width. An idea ?

Here my MWE (For tikz, I use the example 5 of the third document p.5 named : position a specific symbol at line, but maybe I don't need tikz for what I want ?) :

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = arara
\documentclass{scrbook}
\usepackage{fontspec,collect,multido,lipsum}
\newcounter{extrait}\newcounter{fiche}% for my automatic command
\usepackage[framemethod=tikz,usetwoside]{mdframed}
\usetikzlibrary{calc,arrows}
\tikzset{warningsymbol/.style={rectangle, fill=white, scale=1,    overlay}}
% here begin my automatic command using collect, counter, & mdframed
\newcommand\histoire[2]{\addtocounter{fiche}{1}\definecollection{his\thefiche}
\def\histo{\path let \p1=(P), \p2=(O) in ($(\x2,0)+{0.5}*(-1,\y1)$)}% this is my use of TIKZ (\histo is to simplify later)
\mdfsetup{hidealllines=true, leftline=true, leftmargin=0em,innertopmargin=0em, innerbottommargin=0em, innerrightmargin=1.5em, innerleftmargin=0.5em,% 
firstextra={\histo node[warningsymbol] {\rotatebox[origin=c]{90}{#1 …}};},% 
secondextra={\histo node[warningsymbol] {\rotatebox[origin=c]{90}{… #1}};},% 
middleextra={\histo node[warningsymbol] {\rotatebox[origin=c]{90}{… #1 …}};},% 
singleextra={\histo node[warningsymbol] {\rotatebox[origin=c]{90}{#1}};}} 
\begin{mdframed}
{\begin{collect*}{his\thefiche}{}{}{\minisec{Extrait \addtocounter{extrait}{1}\theextrait : #1}}{}#2\end{collect*}}
\end{mdframed}}% end of my command

\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}
% arara: xelatex
% arara: xelatex

This is the actual situation (in red, an example what I hope on the page 1, imagine a similar brace, longer, in the second page) :

enter image description here

1
  • decorations.text can draw braces. But I'm not sure if that's what you want....
    – cfr
    Sep 21, 2015 at 3:12

1 Answer 1

3

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.

You must log in to answer this question.

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