![グリッド状の tikz 図の拡大問題](https://rvso.com/image/309881/%E3%82%B0%E3%83%AA%E3%83%83%E3%83%89%E7%8A%B6%E3%81%AE%20tikz%20%E5%9B%B3%E3%81%AE%E6%8B%A1%E5%A4%A7%E5%95%8F%E9%A1%8C.png)
私の目標は、映画のシーケンスから多くの写真があり、それらを降順でタイプセットするプロセスを自動化することです。そのために、すべての画像はフォルダーに保存され、もちろん、末尾にファイル インデックスが付いた名前が付けられています。私は を選択しましたがmatrix
、柔軟性がある限り (合計幅、ミニチュア幅、列数の 3 つのパラメーターに基づく)、 で作成されたものなら何でもtikz
結構です。
% !TeX encoding = UTF-8
% !TeX spellcheck = fr_FR
\documentclass[11pt, frenchb, twoside]{report}
% IMPORTS
\usepackage{polyglossia}
\usepackage{xparse}
\usepackage{xifthen}
\usepackage{tikz}
\usetikzlibrary{backgrounds, patterns, shapes,
calc, positioning,
matrix, scopes,
decorations.fractals, decorations.text}
\newlength{\foolen}
\newlength{\barlen}
% GRIDFIGURES % % % % % % % % % % % % % % % %
% #1 total width [default: \textwidth]
% #2 total figures
% #3 total columns
% #4 gutter space
% #5 folder
% #6 label
\ProvideDocumentCommand \gridFigures{ O{\textwidth} m m m m m }
{%
\let\gridcontent\empty
\let\ea\expandafter%
\pgfmathsetlength{\foolen}{(#1/#3)-#4}
\pgfdeclareimage[width=\foolen]{ghost}{../assets/#5/#6-1}
\settoheight{\barlen}{\pgfuseimage{ghost}}
%
\foreach \i in {1,2,...,#2}
{%
\pgfmathparse{mod(\i,#3)}
\pgfmathtruncatemacro{\mod}{\pgfmathresult}
\ifthenelse{\mod>0}
{\ea\gappto\ea\gridcontent\ea{\ea{\i} \&}}
{\ea\gappto\ea\gridcontent\ea{something \ea{\i} \\}}}
\begin{tikzpicture}
\matrix[matrix of nodes, ampersand replacement=\&]{\gridcontent};
\end{tikzpicture}}
\begin{document}
\begin{figure}[ht]
\gridFigures{40}{5}{5mm}{mohr}{cubic-limit}
\end{figure}
\end{document}
今のところ、展開の問題で、画像番号でマトリックスを埋めることができません。\i
内のファイル インデックス ( )を使用して画像を再構築するには\foreach
、i
直後に展開する必要があります\ea\gappto\ea\gridcontent\ea
。そうしないと機能しません。展開が何であるかを実際に理解し始めたのは今回が初めてなので、何かが欠けている可能性があります。
答え1
\documentclass{article}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc, positioning, matrix, scopes}
\tikzset{nosep/.style={inner sep=0pt,outer sep=0pt}}
% GRIDFIGURES % % % % % % % % % % % % % % % %
% #1 total width [default: \textwidth]
% #2 macro for matrix content
% #3 total figures
% #4 total columns
% #5 gutter space
% #6 folder
% #7 label
\ExplSyntaxOn
\ProvideDocumentCommand \gridFigures{ O{\textwidth} m m m m m m }
{%
\tl_clear_new:N #2
\dim_new:N \l_width_dim
\pgfmathparse{#3-1}
\pgfmathtruncatemacro{\row}{\pgfmathresult}
\pgfmathsetlength{\l_width_dim}{(#1/#4)-#5}
\int_step_inline:nnnn {1}{#4}{\row}
{
\pgfmathparse{##1+#4-1}
\pgfmathtruncatemacro{\col}{\pgfmathresult}
\int_step_inline:nnnn {##1}{1}{\col}
{
\tl_put_right:Nn #2 {\includegraphics[width=\l_width_dim]{#6/#7-####1}}
\int_compare:nT {####1<\col}
{\tl_put_right:Nn #2 {\&}}
}
\tl_put_right:Nn #2 {\\}
}
}
\ExplSyntaxOff
\begin{document}
\gridFigures{\matrixContent}{40}{5}{2mm}{../assets/mohr}{cubic-limit}
\begin{tikzpicture}[nosep]
\matrix[matrix of nodes,ampersand replacement=\&,
column sep=2mm,row sep=2mm]{\matrixContent};
\end{tikzpicture}
\end{document}