我正在尝试使用其他帖子中建议的解决方案,在多个单元格周围放置一个矩形。
然而,由于某种原因,我的多个单元格矩形最终超出了表格范围,而我不明白为什么。
这是 MWE:我希望圆角正方形适合爱尔兰行中的 88 和 11-13 左右。
非常感谢。
\documentclass{beamer}
\usepackage{etex}
\usepackage{mathtools}
\reserveinserts{28}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{bm}
\usepackage[font=small]{caption}
\usepackage{array}
\makeatletter
\usepackage{tikz}
\usetikzlibrary{fit,shapes.geometric}
\newcounter{nodemarkers}
\newcommand\circletext[1]{%
\tikz[overlay,remember picture]
\node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};%
#1%
\tikz[overlay,remember picture]
\node (marker-\arabic{nodemarkers}-b) at (0,0){};%
\tikz[overlay,remember picture,inner sep=3pt]
\node[draw, red, ultra thick, rounded corners,fit=(marker-\arabic{nodemarkers}-a.center) (marker-\arabic{nodemarkers}-b.center)] {};%
\stepcounter{nodemarkers}%
}
\renewcommand{\itemize}[1][]{%
\beamer@ifempty{#1}{}{\def\beamer@defaultospec{#1}}%
\ifnum \@itemdepth >2\relax\@toodeep\else
\advance\@itemdepth\@ne
\beamer@computepref\@itemdepth% sets \beameritemnestingprefix
\usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
\usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
\usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
\list
{\usebeamertemplate{itemize \beameritemnestingprefix item}}
{\def\makelabel##1{%
{%
\hss\llap{{%
\usebeamerfont*{itemize \beameritemnestingprefix item}%
\usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
}%
}%
}
\fi%
\beamer@cramped%
\justifying
\beamer@firstlineitemizeunskip%
}
\makeatother
\usetheme{Frankfurt}
\usefonttheme[onlylarge]{structurebold}
\setbeamerfont*{frametitle}{size=\normalsize,series=\bfseries}
\addtobeamertemplate{block begin}{}{\justifying}
\setbeamercolor{bibliography item}{fg=black} %new code
\defbeamertemplate*{footline}{shadow theme}{%
\leavevmode%
\hbox{\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm plus1fil,rightskip=.3cm]{title in head/foot}%
\usebeamerfont{title in head/foot}\hfill\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertshorttitle\hfill%
\insertframenumber\,/\,\inserttotalframenumber
\end{beamercolorbox}}%
\vskip0pt%
}
% Standard packages
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
% Setup TikZ
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzstyle{block}=[draw opacity=0.7,line width=1.4cm]
% Author, Title, etc.
% The main document
\begin{document}
\newcounter{nodecount}
% Command for making a new node and naming it according to the nodecount counter
\newcommand\tabnode[1]{\addtocounter{nodecount}{1} \tikz \node (\arabic{nodecount}) {#1};}
\begin{frame}{Identification of the Fiscal Episodes (1970-2013) (cont'd)}
\begin{table}[!p]
\scalebox{0.47}{
\begin{tabular}{cccccccccccc}
\toprule
\midrule
& & & \multicolumn{2}{c}{\textbf{\textit{FE\textsuperscript{1}}}} & & \multicolumn{2}{c}{\textbf{\textit{FE\textsuperscript{2}}}} & & \multicolumn{2}{c}{\textbf{\textit{FE\textsuperscript{3}}}} & \\
\cmidrule{2-2} \cmidrule{4-5} \cmidrule{7-8} \cmidrule{10-11}
& \textbf{ Country} & \textbf{} & \textbf{Expansions} & \textbf{Contractions} & \textbf{} & \textbf{Expansions} & \textbf{Contractions} & \textbf{} & \textbf{Expansions} & \textbf{Contractions} & \\
\cmidrule{2-11}
& \multirow{2}[4]{*}{\textbf{Ireland}} & \textbf{} & 01-02, & \tabnode{88,} & & 95, 01-02, & \circletext{88}, & & 95, 01-02, & \circletext{88}, & \\
& & \textbf{} & 07-10 & \tabnode{11-13} & & 07-10 & \circletext{11-13} & & 07-10 & \circletext{11-13} & \\
\cmidrule{2-11}
& \multirow{2}[4]{*}{\textbf{Italy}} & \textbf{} & & 83, 92-94, & & 81, & 82-83, & & 81, & 82-83, & \\
& & \textbf{} & & 12 & & 01 & 92-93, 12 & & 01 & 92-93, 12 & \\
\cmidrule{2-11}
& \multirow{2}[4]{*}{\textbf{Netherlands}} & \textbf{} & 02, & 91, & & 01-02, & 91, 93, & & 01, & 91, 93, & \\
& & \textbf{} & 09-10 & 93 & & 09-10 & 96 & & 09 & 96 & \\
\cmidrule{2-11}
& \multirow{2}[4]{*}{\textbf{Portugal}} & \textbf{} & 78-80, 94, & 83-84, & & 78-79, 85, 93-94, & 83-84, 86, 88, & & 78, 85, 93, & 83, 86, 88, & \\
& & \textbf{} & 09-10 & \circletext{11-13} & & 05, 09-10 & 92, \circletext{11-13} & & 05, 09-10 & 92, \circletext{11-13} & \\
\cmidrule{2-11}
& \textbf{Spain} & \textbf{} & 08-11 & 13 & & 08-09 & 13 & & 08-09 & 13 & \\
\cmidrule{2-11}
& \textbf{Sweden} & \textbf{} & 02-03 & 96-99 & & 02 & 96-97 & & 02 & 96-97 & \\
\cmidrule{2-11}
& \multirow{2}[4]{*}{\textbf{United Kingdom}} & \textbf{} & 91-93, & 97-00, & & 90-93, & 97-98, 00, & & 90, 92-93, & 00, 11 & \\
& & \textbf{} & 01-04, 09 & 11-13 & & 01-03, 09 & 11-12 & & 01-03, 09 & & \\
\cmidrule{2-11}
& \textbf{\# Years with episodes} & \textbf{} & 52 & 62 & & 63 & 61 & & 51 & 50 & \\
& \textbf{Avg duration (years)} & \textbf{} & 1.86 & 2.48 & & 1.62 & 1.65 & & 1.31 & 1.43 & \\
\midrule
\bottomrule
\end{tabular}%
}
\label{tab:addlabel}%
\begin{tikzpicture}[overlay]
% Define the circle paths
\node[draw=blue,rounded corners = 1ex,fit=(1)(2),inner sep = 0pt] {};
\end{tikzpicture}
\end{table}%
\end{frame}
\end{document}
答案1
(旁注:您的示例并不完全是简约的,其中有很多内容根本没有用到。下面我稍微精简了一些。)
您的代码存在一些问题。首先,您需要定义中的宏和绘制框的环境remember picture,overlay
的选项。您还需要放置\tikz
\tabnode
tikzpicture
tikzpicture
里面这\scalebox
。
\documentclass{beamer}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{tikz}
\usetikzlibrary{fit}
\newcounter{nodemarkers}
\newcommand\circletext[1]{%
\tikz[overlay,remember picture]
\node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};%
#1%
\tikz[overlay,remember picture]
\node (marker-\arabic{nodemarkers}-b) at (0,0){};%
\tikz[overlay,remember picture,inner sep=3pt]
\node[draw, red, ultra thick, rounded corners,fit=(marker-\arabic{nodemarkers}-a.center) (marker-\arabic{nodemarkers}-b.center)] {};%
\stepcounter{nodemarkers}%
}
\newcounter{nodecount}
% Command for making a new node and naming it according to the nodecount counter
\newcommand\tabnode[1]{\stepcounter{nodecount} \tikz[remember picture,overlay] \node (n\arabic{nodecount}) {#1};}
\begin{document}
\begin{frame}
\scalebox{0.47}{
\begin{tabular}{*{10}{c}}
\toprule
& \multicolumn{2}{c}{\textbf{\textit{FE\textsuperscript{1}}}} & & \multicolumn{2}{c}{\textbf{\textit{FE\textsuperscript{2}}}} & & \multicolumn{2}{c}{\textbf{\textit{FE\textsuperscript{3}}}} \\
\cmidrule{1-1} \cmidrule{3-4} \cmidrule{6-7} \cmidrule{9-10}
\textbf{ Country} & & \textbf{Expansions} & \textbf{Contractions} & & \textbf{Expansions} & \textbf{Contractions} & & \textbf{Expansions} & \textbf{Contractions} \\
\midrule
\multirow{2}[4]{*}{\textbf{Ireland}} & & 01-02, & \tabnode{88,} & & 95, 01-02, & \circletext{88}, & & 95, 01-02, & \circletext{88}, \\
& & 07-10 & \tabnode{11-13} & & 07-10 & \circletext{11-13} & & 07-10 & \circletext{11-13} \\
\bottomrule
\end{tabular}%
\begin{tikzpicture}[overlay,remember picture]
% Define the circle paths
\node[draw=blue,rounded corners = 1ex,fit=(n1)(n2),inner sep = 0pt] {};
\end{tikzpicture}
} % <-- this is the end of the scalebox
\end{frame}
\end{document}