# Automatic mark my text with margin braces without using box [closed]

I use the tcolorbox or mdframed advantages for several months to mark my text automatically, according to Gonzalo Medina tips in question Automatic margin curly braces text on multiple pages. But I would like to go beyond disadvantages, and I come back to the community.

What are my problems? Firstly, the decoration TikZ library offers limited choice of braces or some to complex learning. Secondly, if I want to cut within a sentence or a paragraph, the use of boxes makes two or three paragraphs (one before, the box and one after), and I don't want that. But schemata, minipage, mdframed, tcolorbox etc. use boxes and cut my sentences & paragraphs when I mark inside.

Here is what I like:

1. simplicity & flexibility of the \} use — or ) \], \langle, Vert…— like in the Andrew Swann answer to the Big brackets around text question (It would be ideal for me to use braces, brackets or parens as in music or in old editions, but I know, it's difficult to combine typographic quality & lengths management), or better;
2. ingenuity of \tikzmark for pointed mark in a text, like in the David Carlisle basic usage in Margin notes with a pointing arrow… article;
3. usefulness of four display modes developed by mdframed or tcolorbox packages: a single page, or first part, middle part, last part mentioned in the previous question;
4. use of margin notes in odd page & even page.

I imagine we would build a function that combines the brace use \} (or something like musixtex braces) and the \tikzmark{} or \pgfmark{} if I don't need TikZ. In this way, with counter, I mark my text like that \mark{Note}{Text}. If text crosses pages, I imagine that something like finaltextmark and begintextmark exist in LaTeX. A dreamed example :

\newcounter{mark}\newcommand\complexmark[2]{\setcounter{mark}{0}% counter null
\tikzmark{\thecounter}% mark one
\marginnote[{\{}#2]{{\}}#2}% the margin note & brace between mark \tikzmark{1} & \tikzmark{1}, how?
#1% the texte. if we meet a end page before the mark two, end the brace & open other one in te next page
\tikzmark{\thecounter}}% mark two end.


I illustrate my problems here. Thanks.

% !TEX TS-program = arara
\documentclass{scrbook}
\usepackage[no-math]{fontspec}% no-math for musixtex
\usepackage{multido,xparse,lipsum,schemata,marginnote}
\usepackage{changepage}\strictpagecheck
\usepackage[many]{tcolorbox}
\usepackage{tikz}\usetikzlibrary{calc,arrows,decorations.pathreplacing,tikzmark}\tikzset{remember picture}
% methode 2
\newsavebox{\leftbox} \newsavebox{\rightbox}
\NewDocumentCommand{\lrboxbrace}{s O{\{} O{\}} O{0.1\linewidth} m O{0.8\linewidth} m}{% \lrboxbrace[<lbrace>][<rbrace>][<lwidth>]{<ltext>}[<rwidth>]{<rtext>}
\begin{lrbox}{\leftbox}\IfBooleanTF{#1}{\begin{varwidth}{#4}#5\end{varwidth}}{\begin{minipage}{#4}#5\end{minipage}}\end{lrbox}
\begin{lrbox}{\rightbox}\IfBooleanTF{#1}{\begin{varwidth}{#6}#7\end{varwidth}}{\begin{minipage}{#6}#7\end{minipage}}\end{lrbox}
\ensuremath{\usebox\leftbox\left#2\,\usebox\rightbox\,\right#3}}
% method 4
\NewDocumentCommand \margincallout {O{} m m +m }{% \margincallout{<mark1>}{<mark2>}{<note>}
\marginnote{\begin{tikzpicture}[overlay,remember picture]
\node [anchor=west, text width=\marginparwidth, align=left, font=\small,#1]  at (0,0) {#4};
\draw[->] (-0.5,1.94) -- (pic cs:#2); \draw[->] (-0.5,0) -- (pic cs:#3);\draw[decoration=brace,decorate,thick] (-0.3,1.94) -- (-0.3,0); \end{tikzpicture}}}
%method 5
\newtcolorbox{tcbdecor}[1]{%\begin{tcbdecor}{<note>}<text>\end{tcbdecor}
colback=white, boxrule=0pt, colframe=white,  arc=0pt,  outer arc=0pt,  top=0pt,  bottom=0pt,%
check odd page,breakable,enhanced jigsaw,oversize,%
overlay={\ifoddpage\draw[decoration={brace,mirror},decorate] (frame.north east) -- node[rotate=90,above=4pt] {#1} (frame.south east);%
\else\draw[decoration={brace,mirror},decorate] (frame.north west) -- node[rotate=90,above=4pt] {#1} (frame.south west);\fi}}

\begin{document}
\paragraph{1}\textsc{Quality and variety of brackets}%
\marginnote{\startextract \emph{Stylish}\zendextract}
\paragraph{MusiX\TeX}\emph{I love typographic quality (9/10) and resizing of curly brackets (2 choices), but I don't know how to use them for text. Look this graceful brackets in margin:}
\paragraph{savebox} \emph{I like the simple use (5/10) on the code of typographic bracket signs (more than 5 choices): [square], (round), {\{}curly{\}}, <angle>, or |vertical bars||. But…}

\lrboxbrace[\Vert][{)}]{\emph{I'm Grouchy Smurf}}{\emph{… it doesn't cross pages and cuts my sentences !} \lipsum[2]}

\paragraph{schemata} \emph{I like (5/10) the use of braces, brackets and parens (3 choices) with the schemata package and his simplicity. But…}

\schema[close]{\emph{… it doesn't cross pages and cuts my sentences !} \lipsum[2]}{\noindent{\emph{This is why\\I don't like boxes}}} %

\paragraph{2}\textsc{Don't cut sentences and cross pages}%
\paragraph{tikzmark} \emph{I discover tikzmark, and I like the fonctionnement. But… I don't want to use the TikZ decorates, I find them (some choices) misfit (3/10). If we can mark the \textbf{beginning}\tikzmark{a} and the end of a page with tikzmark, we save the \emph{cut sentence} problem. (What you see on the sidelines is not so bad) But we stay with two problems:\begin{itemize}
\item how manage cross pages and vertical length?
\item how put the (good) bracket between beginning and \textbf{end}\tikzmark{b} marks in (good) margin?
\margincallout{a}{b}{Tikzmark with marginpar or marginnote doesn't cut anything! But length, automate, insert a good brace, crossing pages without box… seems difficult.}
\end{itemize}}

\paragraph{mdframed, tcolorbox} \emph{I like crossing pages with mdframed or tcolorbox, but…}
\begin{tcbdecor}{I don't like TikZ decorates}\emph{… if it crosses pages, it continues to cut sentences ! I hope you understand my problems, and if if you find something to help me, I would be very happy. Thank you very much!}\
\lipsum[1]\end{tcbdecor}
\end{document}
% arara: xelatex
% arara: xelatex
% arara: xelatex

• I'm sorry, but I am not quite able to see what you mean here. Could you possibly elaborate or add som images to explain better? – Runar Jul 7 '16 at 17:37
• @RunarTrollet I just edit it to be clearer. My english is bad, sorry – Zouib Jul 8 '16 at 11:38
• I think this is far too much to be answered in an answer here. You're asking for a new package, basically, which needs to be considerably more flexible than several sophisticated current options. – cfr Jul 11 '16 at 0:14
• @cfr Thank you for your analysis. I better understand my difficulty. – Zouib Jul 11 '16 at 8:49