简单的 if 语句 latex

简单的 if 语句 latex

难以理解基本的乳胶操作,我想使用:如果不是(x 和 y 之间的数字):循环中的下一次迭代有人能帮我用一个简单的 if 语句吗?

\newread\reader
\newcount\TotalFiles  


\makeatletter
\newcommand\IterateImages[2]{%
% #1: directory path with a trailing /
% #2: a list of file extensions: eps pdf jpg png
\immediate\write18{batch "#1" \jobname\space #2}
\openin\reader=\jobname.list\relax
\newcounter{figurecounter}\setcounter{figurecounter}{1}
\loop
    \read\reader to \filename
    \unless\ifeof\reader
    \filename@parse{\filename}
    %\section*{\filename}
    \
    \vfill
    \begin{figure}[!htb]
    \begin{center}
            \includegraphics[scale=0.5]{"#1\filename@base"}
    \caption{{\bf text}
    \label{fig:item\thefigurecounter}
    \end{center}
    \end{figure}
    \vfill
    \
    \stepcounter{figurecounter}
    \endgraf
    \advance\TotalFiles1\relax
    \clearpage
\repeat
\closein\reader
}

答案1

感谢请不要触摸评论中给出的指示,遍历文件夹中的每一张图片,可以吗?,对该 MWE 进行以下修改,允许将图片范围指定为 的参数 3 和 4。\IterateImages允许插入范围的逻辑由代码给出:

\ifnum\TotalFiles<#3\relax\else\ifnum\TotalFiles>#4\relax\else
  [Do something if current index is in the range #3, #4, inclusive]
\fi\fi

请注意,引用的答案中提供了文件 batch.bat。

% filename.tex must be compiled with 
% pdflatex -shell-escape filename.tex 
\documentclass[preview,border=12pt]{article}
\usepackage{graphicx}

\newread\reader
\newcount\TotalFiles    
\newcount\UsedFiles

\makeatletter
\newcommand\IterateImages[4]{%
% #1: directory path with a trailing /
% #2: a list of file extensions: eps pdf jpg png
\immediate\write18{batch "#1" \jobname\space #2}
\openin\reader=\jobname.list\relax
\loop
    \read\reader to \filename
    \unless\ifeof\reader
    \filename@parse{\filename}
    \advance\TotalFiles1\relax
    \ifnum\TotalFiles<#3\relax\else\ifnum\TotalFiles>#4\relax\else
      \advance\UsedFiles1\relax
      \section*{\filename}
      \begin{center}
            \includegraphics[scale=0.1]{"#1\filename@base"}
      \end{center}
      \endgraf
    \fi\fi
    \repeat
\closein\reader
}
\makeatother



\begin{document}
% ./ also works
\IterateImages{./}{png}{2}{6}

\section*{Summary}
There is(are) \the\TotalFiles\ file(s) in total.\\
Of them, \the\UsedFiles\ were employed.
\end{document}

在此处输入图片描述

相关内容