I asked similar question here Colored Curly Brackets spanning across multiple pages but may be I did not provide enough detail. On its own the solution works great.

I have about 32 longtables in my document with varying row numbers ranging anywhere from 40 to 250. Longtable was the choice because I wanted my data in a columns, which gave nice alignment and text wrapping. There are sections and subsections at the beginning of each longtable. Upto this point life is good. This is where I became bit greedy.

I wanted to show curly or square brackets on the left side, these braces needs to span across pages and can start from one table and terminate anywhere in the next table. Some braces need to span about 5 or 6 long tables.

I thought of using tikz overlay but could not find any example where I can see how to span braces across pages. I am attaching a sample image created in word to better explain the need. In the attached image the brown vertical and horizontal line are legacy of MS word screen shot and does have to the part of tex solution.

Any examples, help or documentation would be appreciated. enter image description here

  • The reason for the absence of such examples is because I don't think it's is possible without manually breaking the brace at the page bottom and starting from above in the next page. Maybe something with mdframed mechanism can be hacked for this. Since it automatically breaks down boxes, it can keep track of started \tikzmarks. So I leave to floor to @MarcoDaniel .
    – percusse
    Oct 26, 2012 at 0:11

1 Answer 1


Update 2

Well, with Andrew Stacey's everybody's favorite TikZ library tikzmark it is a little bit easier.
You need to download the file tikzmark.dtx and run it through pdflatex. If it requests and _example file, ignore. You'll get two files tikzlibrarytikzmark.code.tex and tikzlibrarytikzmarkextras.code.tex. Place them in the directory of your working .tex file or in your local texmf tree. Load it with \usetikzlibrary{tikzmark}.

I personally don't like the style of this brace, maybe I re-add my own style.


Place \bracestart{<identifier>} somewhere where you want the brace to start and \braceend{<identifier>} where it should end. On every page the brace should appear, you have to add

\bracedraw[<brace>]{<identifier>}{<level>}{<node [] argument>}{<node text>}

where <brace> will be used for the internally brace \draw.

At the moment, the brace's nipple middle part will be at the half of the brace.

To do

  • Automatically re-placement of the middle part and its text.
  • Detection of left or right side placement (for twoside documents with different margins)
  • Better interworking with pgf's key management (everything variable are TeX commands)


    next page=below,
        rounded corners=10pt
\newcommand*{\tikzbracemargindistance}{12.5em} % probably should be some \marginwidth stuff and should handle even/odd pages (twoside)
\newcommand*{\tikzbraceendheight}{\baselineskip-.5ex} % \tikzmark lands in the following par so we cheat ;)

\newcommand{\bracestart}[1]{% #1 = name
\newcommand{\braceend}[1]{% #1 = name
\newcommand{\bracedraw}[5][]{% #1 = optional argument for the brace line
                             % #2 = name
                             % #3 = level
                             % #4 = (mandatory) node argument
                             % #5 = node text
    \tikz[overlay, remember picture] {
        \draw[mymarginbrace, #1]
%           (pic cs:braceend-#2) -- node[#4] {#5} (pic cs:bracestart-#2);
            (perpendicular cs:
                horizontal line through = {(pic cs:braceend-#2)},
                vertical line through = {($(current page.west)+(\tikzbracemargindistance-#3*\tikzbraceleveldistance,0pt)$)})
            -- node[sloped,above=2.5em, #4] {#5}
            (perpendicular cs: horizontal line through = {($(pic cs:bracestart-#2)+(0,\tikzbracestartheight)$)}, vertical line through = {($(current page.west)+(\tikzbracemargindistance-#3*\tikzbraceleveldistance,0pt)$)})
\bracedraw[]{a}{0}{}{Hallo! Text a} % start of a = draw
\bracedraw[]{a}{0}{}{Hallo! Text a} % end of a = draw
\bracedraw[]{b}{1}{}{Text b} % start of b = draw
\bracedraw[]{c}{0}{}{Text c} % start of c = draw
\bracedraw[]{b}{1}{}{Text b} % somewhere bet start and end of b but certainly on another page than start and end
\bracedraw[green]{d}{2}{}{Text d} % start and end only on one page ...

\bracedraw[]{c}{0}{}{Text c} % end of c = draw
\bracedraw[]{b}{1}{}{Text b} % end of b = draw


Sample of three braces at once Text a sample

First draft

I have something of the following in mind [no MWE :( and I haven't looked at your linked question].

Problem with braces will be to calculate the middle where that “nipple” part is.



\newcommand{\tikzmark}[3][]{\tikz[overlay,remember picture] \node[#1] (#2) at (#3) {};}
\tikzmark{pageup}{$(current page.south west)+(4em,0em)$}
\tikz[overlay,remember picture] \draw[very thick] (up) to[out=180,in=95] node [sloped,midway,above] {Where do we go?} (pageup);
\tikzmark{pagedown}{$(current page.north west)+(4em,0em)$}
\tikz[overlay,remember picture] \draw[-latex,very thick] (pagedown) to[out=-85,in=180] node [above,sloped,pos=.8] {Whee!} (down);


First attempt

  • 5
    Wow, that's a very clever idea and you don't have to find the nipple (hey, focus here!) because both parts will be clipped by the page break anyway if you use the brace decoration.
    – percusse
    Oct 26, 2012 at 0:32
  • @Qrrbrbirlbel - I can let go braces, if I can make it a nice straight line with 90 degree turns. I asked for curly braces because they look cool but this serves the purpose. You included the names on the lines thats like bonus on my question.
    – Raama
    Oct 26, 2012 at 0:37
  • 1
    Very nice :-) +1, What is the document is two sided?
    – user11232
    Oct 26, 2012 at 2:30
  • @HarishKumar That depends of whether you want a fixed space between the side of your page and the braces or a fixed space between text and the braces. One could also decide to let the braces jump between left and right margins (i.e. outer or inner). From there it's only checking the oddness and a few calculations with margin dimensions. Oct 26, 2012 at 3:40
  • Sounds like it would be useful if \tikzmark remembered the page number as well as the position on the page. bazaar.launchpad.net/~tex-sx/tex-sx/development/revision/163 Oct 26, 2012 at 10:35

You must log in to answer this question.

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