想要输入一个从第 3 列延伸到第 5 列的箭头。所需的输出显示在图像文件中。请建议如何实现它。我在下面提供了示例 latex 代码。
\documentclass[aspectratio=169]{beamer}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{tabularx}
\begin{document}
\setbeamertemplate{frametitle}[default][center]
\begin{frame}{Comparison}\scriptsize\centering\setlength{\tabcolsep}{4pt}\renewcommand{\arraystretch}{1.7}
\begin{tabular}{l c c c c c}
& Project & Job-shop & Batch & Assembly & Continuous \\
\hline
Flexibility & \onslide<2->{High} & \multicolumn{3}{c}{ \onslide<2->{$\longleftarrow$}} & \onslide<2->{Low} \\
Variety & \onslide<3->{High} & \multicolumn{3}{c}{ \onslide<3->{$\longleftarrow$}} & \onslide<3->{Low} \\
\end{tabular}
\end{frame}
\end{document}
另外,我希望 onslide 中的内容以警报格式显示。示例箭头样式如下所示。
答案1
您可以nicematrix
使用来执行此操作CodeAfter
。您可以TikZ
向箭头添加所需的任何属性。
\documentclass[aspectratio=169]{beamer}
\usepackage{nicematrix,tikz}
\mode<presentation>
\usefonttheme[onlylarge]{structuresmallcapsserif}
\usepackage{charter} % serif
\begin{document}
\setbeamertemplate{frametitle}[default][center]
\begin{frame}{Comparison}\scriptsize\centering\setlength{\tabcolsep}{4pt}\renewcommand{\arraystretch}{1.7}
\begin{NiceTabular}{l c c c c c}
& Project & Job-shop & Batch & Assembly & Continuous \\
\hline
Flexibility & \onslide<2->{High} & & & & \onslide<2->{Low} \\
Variety & \onslide<3->{High} & & & & \onslide<3->{Low} \\
\CodeAfter
\onslide<2->{\tikz\draw[blue,<-] (2.5-|3) -- (2.5-|6);}
\onslide<3->{\tikz\draw[<-] (3.5-|3) -- (3.5-|6);}
\end{NiceTabular}
\end{frame}
\end{document}
答案2
您可以使用\leftarrowfill
\documentclass[aspectratio=169]{beamer}
\begin{document}
\setbeamertemplate{frametitle}[default][center]
\begin{frame}{Comparison}
\scriptsize
\centering
\setlength{\tabcolsep}{4pt}
\renewcommand{\arraystretch}{1.7}
\begin{tabular}{l c c c c c}
& Project & Job-shop & Batch & Assembly & Continuous \\
\hline
Flexibility &
\onslide<2->{High} &
\multicolumn{3}{c}{\onslide<2->{\leftarrowfill}} &
\onslide<2->{Low} \\
Variety &
\onslide<3->{High} &
\multicolumn{3}{c}{\onslide<3->{\leftarrowfill}} &
\onslide<3->{Low} \\
\end{tabular}
\end{frame}
\end{document}
避免utf8x
:它无人维护并且与最新的 LaTeX 版本不兼容。
答案3
另一种可能性是pstricks
,它需要非常短的代码:
\documentclass[aspectratio=169, svgnames]{beamer} % Document class
\usepackage{subcaption}
\usepackage[english]{babel} % Set language
\usepackage{xcolor}
\usepackage{pst-node}
\mode<presentation> % Set options
{
\usetheme{default} % Set theme
\usecolortheme{rose} % Set colors
\usefonttheme{default} % Set font theme
\setbeamertemplate{caption}[numbered] % Set caption to be numbered
}
\usefonttheme[onlylarge]{structuresmallcapsserif}
\usepackage{graphicx} % For including figures
\usepackage{booktabs, caption} % For table rules
\usepackage{hyperref} % For cross-referencing
\setbeamertemplate{footnote}{%
\parindent 1em\noindent%
\raggedright
\insertfootnotetext\par%
}
\usepackage{fontawesome}
\usepackage{charter} % serif
\hypersetup{
pdfnewwindow=true, % links in new window
colorlinks=true, % false: boxed links; true: colored links
linkcolor=gray!20!black, % color of internal links 20% gray and 80%black
citecolor=blue, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=violet % color of external links
}
\usepackage{colortbl}
\usepackage{pdflscape,array,booktabs}
\usepackage[font=scriptsize]{caption}
\usepackage{graphicx}
\usepackage{color}
\usepackage{ragged2e}
\setbeamertemplate{caption}[numbered]
\usepackage{amssymb}
\usepackage{listings}
\usepackage{tabularx}
\usepackage{tikz}
\usepackage[flushleft]{threeparttable}
\usepackage{multirow,makecell}
\usepackage{apacite}
\usepackage{natbib}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{booktabs}
\usepackage{siunitx}
\setbeamerfont{section in toc}{size=\scriptsize}
\setbeamerfont{subsection in toc}{size=\scriptsize}
\begin{document}
\setbeamertemplate{frametitle}[default][center]
\begin{frame}{Comparison}\scriptsize\centering\setlength{\tabcolsep}{4pt}\renewcommand{\arraystretch}{1.7}
\begin{tabular}{l c c c c c}
& Project & Job-shop & Batch & Assembly & Continuous \\
\hline
Flexibility & \onslide<2->\rnode{H}{High} & \multicolumn{3}{c}{ } & \onslide<2->\rnode{L}{Low} \\
Variety & \onslide<3->{High} & \multicolumn{3}{c}{ } & \onslide<3->{Low} \\
\end{tabular}
\psset{arrowinset=0.1}
\ncline[nodesep=3pt, linecolor=CornflowerBlue]{->}{L}{H}
\end{frame}
\end{document}
答案4
和tikzmark
:
\documentclass[aspectratio=169]{beamer}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{arrows.meta}
\tikzset{
myarrow/.style={
-Straight Barb,
blue,
thick,
shorten <=2pt,
shorten >=2pt
}
}
\usepackage{tabularx}
\begin{document}
\setbeamertemplate{frametitle}[default][center]
\begin{frame}{Comparison}\scriptsize\centering\setlength{\tabcolsep}{4pt}\renewcommand{\arraystretch}{1.7}
\begin{tabular}{l c c c c c}
& Project & Job-shop & Batch & Assembly & Continuous \\
\hline
Flexibility & \onslide<2->{\tikzmarknode{fh}{High}} & && & \onslide<2->{\tikzmarknode{fl}{Low}} \\
Variety & \onslide<3->{\tikzmarknode{sh}{High}} & && & \onslide<3->{\tikzmarknode{sl}{Low}} \\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\onslide<2->{\draw[myarrow] (fl) to (fh);}
\onslide<3->{\draw[myarrow] (sl) to (sh);}
\end{tikzpicture}
\end{frame}
\end{document}