![如何圈出表格中的目标项目?](https://linux22.com/image/468268/%E5%A6%82%E4%BD%95%E5%9C%88%E5%87%BA%E8%A1%A8%E6%A0%BC%E4%B8%AD%E7%9A%84%E7%9B%AE%E6%A0%87%E9%A1%B9%E7%9B%AE%EF%BC%9F.png)
我正在使用这个序言LaTeX
\documentclass[10pt]{book}
\usepackage[paperheight=9.5in,paperwidth=8in, top=1in, bottom=0.8in, twocolumn]{geometry}
\setlength{\columnseprule}{0.4pt}
\usepackage{amssymb,amsfonts}
\usepackage{mathrsfs}
\usepackage[centertags]{amsmath}
\usepackage{amsthm}
\usepackage{amsmath}
\newtheorem{theorem}{Theorem}
\usepackage{epsfig}
\usepackage{float}
\usepackage{graphicx}\graphicspath{{Graphics/}}
\usepackage{mathptmx}
\usepackage[square,sort&compress]{natbib}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usetikzlibrary{arrows}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}\pagestyle{fancy}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{enumitem}
\setlist[enumerate,2]{label=(\roman*).}
\usepackage{tasks}
\settasks{label=$\circ$}
%\usepackage{hyperref}
\usetikzlibrary{arrows.meta}
\renewcommand{\baselinestretch}{1.5}
\newcommand\aug{\fboxsep=-\fboxrule\!\!\!\fbox{\strut}\!\!\!}
\theoremstyle{definition}
\newtheorem{Thm}{Theorem}[section]
\newtheorem{lem}[Thm]{Lemma}
\newtheorem{pro}[Thm]{Proposition}
\newtheorem{de}[Thm]{Definition}
\newtheorem{re}[Thm]{Remark}
\newtheorem{ex}[Thm]{Example}
\newtheorem{cor}[Thm]{Corollary}
\numberwithin{equation}{section}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\begin{document}
\begin{tabular}{|c|c|c|}\hline
\text{item}\quad$x$&\text{Frequency}$f$&$c.f$\\\hline
10&1&1\\
12&10&11\\
15&5&16\\
20&13&29\\
25&2&31\\
30&4&35\\\hline
\end{tabular}
\end{document}
我不知道如何圈出目标项目,如下图所示。
答案1
在图书馆的帮助下tikzmark
:
\documentclass[10pt]{book}
\usepackage[paperheight=9.5in,paperwidth=8in,
top=1in, bottom=0.8in, twocolumn]{geometry}
\setlength{\columnseprule}{0.4pt}
\usepackage{tikz}
\usetikzlibrary{fit, % new
tikzmark} % new
\tikzset{FIT/.style = {%
draw=red, thick, inner sep=2pt, rounded corners, fit=#1,
node contents={}},
s/.style= {inner xsep=6pt}
}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
item \quad$x$
& Frequency $f$
& $c.f$ \\
\hline
10 & 1 & 1 \\
12 & 10 & 11 \\
15 & 5 & 16 \\
\tikzmarknode[s]{a}{20}
& 13 & \tikzmarknode[s]{b}{29} \\
25 & 2 & 31 \\
30 & 4 & 35 \\
\hline
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\node[FIT=(a) (b)];
\end{tikzpicture}
\end{document}
或者使用椭圆圈出表格中的目标项目:
\documentclass[10pt]{book}
\usepackage[paperheight=9.5in,paperwidth=8in,
top=1in, bottom=0.8in, twocolumn]{geometry}
\setlength{\columnseprule}{0.4pt}
\usepackage{tikz}
\usetikzlibrary{fit, % new
tikzmark,
shapes.geometric} % new
\tikzset{FIT/.style args = {#1/#2}%
{ellipse, draw=red, thick, inner xsep=#1, inner ysep=2pt, fit=#2,
node contents={}},
}
\usepackage{array}
\begin{document}
\begin{table}[ht]
\centering
\renewcommand\arraystretch{1.2}
\begin{tabular}{|w{c}{4em}|c|w{c}{4em}|}
\hline
item \quad$x$
& Frequency $f$
& $c.f$ \\
\hline
10 & 1 & 1 \\
12 & 10 & 11 \\
15 & 5 & 16 \\
\tikzmarknode{a}{20}
& 13 & \tikzmarknode{b}{29} \\
25 & 2 & 31 \\
30 & 4 & 35 \\
\hline
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\node[FIT=-9pt/{(a) (b)}];
\end{tikzpicture}
\end{table}
\end{document}
答案2
这是一个{NiceTabular}
使用 的解决方案nicematrix
。
\documentclass[10pt]{book}
\usepackage[paperheight=9.5in,paperwidth=8in,
top=1in, bottom=0.8in, twocolumn]{geometry}
\setlength{\columnseprule}{0.4pt}
\usepackage{nicematrix,tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{NiceTabular}{ccc}[vlines]
\hline
item\quad $x$ & Frequency $f$ & $c.f$ \\
\hline
10 & 1 & 1 \\
12 & 10 & 11 \\
15 & 5 & 16 \\
20 & 13 & 29 \\
25 & 2 & 31 \\
30 & 4 & 35 \\
\hline
\CodeAfter
\tikz \node [ draw = red, rounded corners, fit = (5-1) (5-3) ] { } ;
\end{NiceTabular}
\end{document}