3

I am using this preamble of 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}

I don't know how to encircle the targeted item as shown in the picture below.

enter image description here

Ingmar
  • 6,690
  • 5
  • 26
  • 47
  • See https://tex.stackexchange.com/questions/489942/beamer-shading-columns-and-highlight-extra, if can help you. – Zarko Aug 27 '23 at 04:19

2 Answers2

5

With help of tikzmark library:

\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}

enter image description here

or with use ellipse for encircling target items in table:

\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}

enter image description here

Zarko
  • 296,517
4

Here is a solution with {NiceTabular} of 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}

Output of the above code

F. Pantigny
  • 40,250