如何使用 \includegraphics 放置图表目录?

如何使用 \includegraphics 放置图表目录?

我想生成一个7x7的表格,表格的每个单元格都是一个图形。图形是Graph1,Graph2,...,Graph49。

目前我正在\includegraphics[width=0.1\textwidth]{fig/Graph1} ...手动输入这一行 49 次。

我想知道是否有任何聪明的方法可以做到这一点?

答案1

可以设置一个循环来执行此操作,但在表格中有点棘手,而且如果您决定要突出显示第 3 行,或者\hline在第 6 行和第 7 行之间放置一个,则很难灵活处理。相反,我只会使用 tex 宏系统

\newcommand\myincl[2]{%
\includegraphics[width=0.1\textwidth]{fig/Graph\the\numexpr(#1-1)*7+#2\relax}}

根据您希望顺序向下或横向进行,您可以在定义中#1切换。#2

然后

\myincl{1}{1}&\myincl{1}{2}&\myincl{1}{3}&\myincl{1}{4}&\myincl{1}{5}&\myincl{1}{6}&\myincl{1}{7}\\
\myincl{2}{1}&\myincl{2}{2}&\myincl{2}{3}&\myincl{2}{4}&\myincl{2}{5}&\myincl{2}{6}&\myincl{2}{7}\\
\myincl{3}{1}&\myincl{3}{2}&\myincl{3}{3}&\myincl{3}{4}&\myincl{3}{5}&\myincl{3}{6}&\myincl{3}{7}\\
\myincl{4}{1}&\myincl{4}{2}&\myincl{4}{3}&\myincl{4}{4}&\myincl{4}{5}&\myincl{4}{6}&\myincl{4}{7}\\
\myincl{5}{1}&\myincl{5}{2}&\myincl{5}{3}&\myincl{5}{4}&\myincl{5}{5}&\myincl{5}{6}&\myincl{5}{7}\\
\myincl{6}{1}&\myincl{6}{2}&\myincl{6}{3}&\myincl{6}{4}&\myincl{6}{5}&\myincl{6}{6}&\myincl{6}{7}\\
\myincl{7}{1}&\myincl{7}{2}&\myincl{7}{3}&\myincl{7}{4}&\myincl{7}{5}&\myincl{7}{6}&\myincl{7}{7}

相关内容