答案1
这是 的一种可能性nicematrix
。您必须编译两次(这会随机更改鸭子)。
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{duckuments}
\usepackage{nicematrix, tikz}
\newcommand{\borderw}{2mm}
\newcommand{\duck}{\includegraphics[width=2cm, height=3cm, valign=m]{example-image-duck}}
\begin{document}
\setlength{\tabcolsep}{2mm}
\NiceMatrixOptions{cell-space-limits = 2mm}
\begin{NiceTabular}{*{7}{c}}
\duck & \duck & \duck & \duck & \duck & \duck & \duck \\
\duck & \duck & \duck & \duck & \duck & \duck & \duck \\
\duck & \duck & \duck & \duck & \duck & \duck & \duck % \goose
\CodeAfter\tikz[line cap=round, line width=1mm, dash pattern=on 0mm off 2mm, gray!50, shorten <=-1cm, shorten >=-1cm]{
\foreach \n in {1,...,8}\draw(1-|\n)--(4-|\n);
\foreach \n in {1,...,4}\draw(\n-|1)--(\n-|8);
}
\end{NiceTabular}
\end{document}
答案2
作为对 Sandy G 答案的补充,这里还有另一个使用 的答案。它定义了一个自定义的线条样式(使用 中的nicematrix
键)并在 中使用字母(用于垂直规则)和命令用于水平规则。custom-line
\NiceMatrixOptions
{NiceTabular}
I
MyHline
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{duckuments}
\usepackage{nicematrix, tikz}
\newcommand{\borderw}{2mm}
\newcommand{\duck}{\includegraphics[width=2cm, height=3cm, valign=m]{example-image-duck}}
\begin{document}
\setlength{\tabcolsep}{2mm}
\NiceMatrixOptions
{
cell-space-limits = 2mm ,
custom-line =
{
letter = I ,
command = MyHline ,
tikz =
{
line cap=round,
line width=1mm,
dash pattern=on 0mm off 2mm,
gray!50,
shorten <=-1cm,
shorten >=-1cm
}
}
}
\begin{NiceTabular}{cIcIcIcIcIcIc}
\MyHline
\duck & \duck & \duck & \duck & \duck & \duck & \duck \\
\MyHline
\duck & \duck & \duck & \duck & \duck & \duck & \duck \\
\MyHline
\duck & \duck & \duck & \duck & \duck & \duck & \duck \\
\MyHline
\end{NiceTabular}
\end{document}