4

This is a follow-up to my earlier questions here and here. In short, what I want to achieve is an arc over multiple columns, which I am achieving using Tikz. Code is shown below.

\documentclass[12pt]{article}
\usepackage{tikz}
\newcommand{\mulcol}[1]{\multicolumn{2}{c}{#1}}
\usetikzlibrary{decorations.pathmorphing}
\newcommand\myarc[2][]{%
  \tikz[overlay,remember picture] \node at (0,0.4) (a) {};#2%
  \tikz[overlay,remember picture] \node at (0,0.4) (b) {};
  \begin{tikzpicture}[overlay,remember picture,out=35,in=145,distance=0.2cm]
    \draw[#1] (a.center) to (b.center);
  \end{tikzpicture}}

\begin{document}

\begin{center}
\begin{tabular}{*{6}{c}}
\myarc{a&a}&a&a&a&a\\
\myarc{\mulcol{a}}&\mulcol{a}&\mulcol{a}\\
\end{tabular}
\end{center}
\end{document}

Produced output:

Output from the code above

With this the first row gives the correct orientation of the content and the arc above, but the second row offsets the content of the multicol forward (circled red in the figure). What causes this offset to occur and is there any way to correct it?

L__
  • 209

1 Answers1

4

As mentioned in the comment that \multicolumn must be the first thing in a cell. This solution switches myarc and mulcol around and add \hfill to fill the width.

enter image description here

Code

\documentclass[12pt]{article}
\usepackage{tikz}
\newcommand{\mulcol}[1]{\multicolumn{2}{c}{#1}}
\newcommand{\mulcols}[1]{\multicolumn{3}{c}{#1}}  % newly added command
\usetikzlibrary{decorations.pathmorphing}


\newcommand\myarc[2][]{%
  \tikz[overlay,remember picture] \node at (0,0.4) (a) {};#2%
  \tikz[overlay,remember picture] \node at (0,0.4) (b) {};
  \begin{tikzpicture}[overlay,remember picture,out=35,in=145,distance=0.2cm]
    \draw[#1] (a.center) to (b.center);
  \end{tikzpicture}}

\begin{document}

Case for  multicolumn 2

\begin{center}
\begin{tabular}{*{6}{c}}
\myarc{a&a}&a&a&a&a\\[2pt]
\mulcols{\myarc{\hfill a\hfill}}&\mulcol{a}&\mulcol{a}\\
\end{tabular}
\end{center}
Jesse
  • 29,686
  • I have accepted the answer as it is the most apt for the qn I asked. However, what modification to the above solution would be needed if the same arc is to span the next \multicolumn as well? The scope of the arc seems to restricted to that \multicolumn alone in this case. – L__ Apr 22 '14 at 15:17
  • 1
    @L__ -- In my view, your myarc macro is limitd because the point a and b are the same point. To span to the next multicolumn, you need to redefine myarc -- generating two tikzmarks and put them inside of \mulcol, then connect them with arc. In short, replace \myarc with \tikzmark and then connect them via drawing arc. Here is a reference. http://tex.stackexchange.com/a/170879/34618 – Jesse Apr 22 '14 at 16:38
  • Formed the more general and powerful macro from info in the above link that you gave. Thanks!! – L__ Apr 25 '14 at 11:11