부동 조판 시(정의 시 아님) 매크로 확장

부동 조판 시(정의 시 아님) 매크로 확장

내가 아는 한, float 환경의 내용은 float가 정의될 ​​때 상자에 들어갑니다. 부동 소수점이 실제로 조판될 때 사용자 정의 명령/매크로를 처리하는 것이 가능합니까? 예를 들어 특정 페이지(반드시 부동 소수가 정의된 페이지일 필요는 없음)에 워터마크를 삽입할 수 있습니까?

부동 환경 정의에 무언가를 추가해야 합니까, 아니면 해당 본문 내에서 일부 명령을 사용할 수 있습니까?

답변1

특정 유형의 플로트가 나타나는 페이지에서 워터마크만 찾는 경우 다음을 사용하여 배송 루틴을 활용할 수 있습니다.atbegshi플로트 카운터 추적 메커니즘을 사용하여 일부 카운터 마법을 조건으로 합니다.

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage{atbegshi,refcount,etoolbox,graphicx,xcolor}
\usepackage{lipsum,afterpage}

\newcounter{floatcntr}
\AtEndEnvironment{figure}{\refstepcounter{floatcntr}\label{floatcntr@\roman{floatcntr}}}
\newcounter{floatsearch}\setcounter{floatsearch}{1}

\AtBeginShipout{%
  \ifnum\value{page}>\getpagerefnumber{floatcntr@\roman{floatsearch}}
    \stepcounter{floatsearch}% In case there are multiple (2) floats on the same page
  \fi
  \ifnum\value{page}=\getpagerefnumber{floatcntr@\roman{floatsearch}}
    \AtBeginShipoutUpperLeft{%
      \parbox[t]{\pdfpagewidth}{\centering\bfseries\sffamily%
        \vspace{.4\pdfpageheight}%
        \resizebox{.7\pdfpagewidth}{!}{\textcolor{red!80}{DRAFT}}}
    }%
    \stepcounter{floatsearch}
  \fi
}

\begin{document}

\lipsum[1-3]

\begin{figure}[ht]
  \centering\includegraphics[width=.6\linewidth]{example-image}
  \caption{A figure}
\end{figure}

\lipsum[4-12]

\afterpage{\clearpage}% Just to flush the float
\begin{figure}[p]
  \centering\includegraphics[width=.6\linewidth]{example-image}
  \caption{A figure}
\end{figure}

\lipsum[13-25]

\end{document}

위의 MWE는 floatcntr모든 figure. 그런 다음 참조는 출고 시 페이지 번호와 비교되며, 일치하는 경우 일부 배경 콘텐츠가 표시됩니다.

figure주의 사항: 위 설정에서는 페이지당 2개 이하를 가정합니다 . 더 많은 경우(가능성이 거의 없음) 일부 수정이 필요할 수 있습니다.

관련 정보