如何圈出表格中的目标项目?

如何圈出表格中的目标项目?

我正在使用这个序言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}

上述代码的输出

相关内容