ドキュメント全体で各ページに を使用してヘッダーを付けていますが\usepackage{fancyhdr}
、大きな図のある特定のページではヘッダーをオフにしたいと\thispagestyle{empty}
考えています。 を正しく使用すると、ヘッダーは削除されますが、ランダムなページのみです。\newpage
図の直前に を配置してから を使用することで、適切なページに効果を適用できると思いました\thispagestyle{empty}
が、結果は同じです。 図専用の を新しく作成する必要がありますか、それとも.tex
もっと簡単な方法がありますか?
私のmain.tex
文書には\begin{document}
、、、、、と続き、さまざまな文書
\pagestyle{fancy}
が あり ます。特定の文書を見ると、次のようにグラフィックが挿入されたテキストが多数あります。\fancyfoot{}
\lhead{\thepage}
\rhead{\nouppercase{\rightmark}}
.tex
.tex
\begin{figure}
\centering
\hbox{\hspace{-15mm} \includegraphics[scale=0.9]{my-image}}
\caption{my caption}
\label{myfigure}
\end{figure}
画像の直前に\newpage
followed by を置こうとしましたが、間違ったページに適用されてしまいます。コメントで提案されているように試してみましたが、同じことが起こりました。\thispagestyle{empty}
\clearpage
答え1
\documentclass
これは機能するようです (ただし、試行錯誤による解決策については、私たちはあまり知りません)。
\documentclass{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{lipsum} % For text
\begin{filecontents}[overwrite]{chapter1.tex}
\clearpage
\thispagestyle{empty}
\begin{figure}[p]
\centering
\hbox{\hspace{-15mm} \includegraphics[scale=0.9]{example-image-a}}
\caption{my caption}
\label{myfigure}
\end{figure}
\end{filecontents}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{\thepage}
\fancyhead[R]{\nouppercase{\rightmark}}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\begin{document}
\section{Test}
\lipsum[1-8]
\include{chapter1}
\lipsum[1-8]
\end{document}
の部分は、私が作成したファイルfilecontents
の一例にすぎません.tex
。
ページにページ番号を配置するには、[p]
次のようにします。
\documentclass{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{lipsum} % For text
\begin{filecontents}[overwrite]{chapter1.tex}
\clearpage
\thispagestyle{floatp}
\begin{figure}[p]
\centering
\hbox{\hspace{-15mm} \includegraphics[scale=0.9]{example-image-a}}
\caption{my caption}
\label{myfigure}
\end{figure}
\end{filecontents}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{\thepage}
\fancyhead[R]{\nouppercase{\rightmark}}
\renewcommand{\headrulewidth}{0pt}
% ------------ Added
\fancypagestyle{floatp}{%redefining plain pagestyle
\fancyfoot{}
\fancyhead{}
\fancyfoot[R]{\thepage} % Page number in bottom right
}
\pagestyle{fancy}
\begin{document}
\section{Test}
\lipsum[1-8]
\include{chapter1}
\lipsum[1-8]
\end{document}
答え2
大きなフロートに\floatpagestyle{empty}
のみ使用する場合はどうでしょうか?[p]
パッケージのマニュアルの\rotfloatpagestyle
およびも参照してください。\thisfloatpagestyle
floatpag
またfancyhdr
、
\iffloatpage{
フロートページの値}{
他のページの価値}
。
\documentclass[twoside]{article}
\usepackage{graphicx}
\usepackage{floatpag}\floatpagestyle{empty}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
\section{foo1}\subsection{foo}\lipsum[1]
\section{foo}\subsection{foo}\lipsum[1]
\section{foo}\subsection{foo}\lipsum[1-2]
\begin{figure}[h]\includegraphics[]{example-image-9x16}\caption{foo}\end{figure}
\section{foo}\subsection{foo}\lipsum[1]
\begin{figure}[p]\centering\includegraphics[]{example-image-9x16}\caption{foo}\end{figure}
\section{foo}\subsection{foo}\lipsum[1]
\section{foo}\subsection{foo}\lipsum[1]
\end{document}
答え3
\pagestyle{empty}
フィギュアが掲載されているページの前のページが発送された後に指令を出す必要があります。
最近のLaTeXリリースでは
shipout/after
、LaTeXがページを出力した直後にコードを実行するためのフックを使用することができます。(\changes
ltshipout.dtxこのフックは2021年1月8日に追加されました。パッケージを使用することができます参照LaTeX が問題の図を配置するページの、いわゆる「絶対ページ番号」の値を格納および取得します。
\CodeAfterShipoutOfAbsolutePage
さらに、絶対ページ番号とコードを指定できるマクロを定義して、shipout/after
絶対ページ番号が指定された値であるページの送信後にのみコードを実行するためのディレクティブがフックに追加されるようにすることもできます。以下の例では、絶対ページ番号は TeX に計算を行わせることで指定できますが、その計算には zref ラベルへのアクセスも含まれる場合があります。したがって、以下の例では
\CodeAfterShipoutOfAbsolutePage
2 つの引数だけではなく 3 つの引数を取ります。そのうちの 1 つは、絶対ページ番号の指定が機能するために定義する必要がある zlabel のコンマ区切りリストを示します。これらの zlabel の 1 つが定義されていない場合 (1 回目のコンパイルの場合も同様)、コードも実行されません。!! したがって、すべてが一致するには少なくとも 2 つのコンパイルが必要です。 !!
の構文は次のように\CodeAfterShipoutOfAbsolutePage
なります。
\CodeAfterShipoutOfAbsolutePage
{<comma-list of zref-labels that must exist for the code to be carried out>%
% Here you specify both those zref-labels that are needed for the
% <expression for computing the absolute page number of the page after
% whose shipping-out code shall be carried out> to work out and probably
% also those zref-labels that are needed for the <code to carry out after
% the page has been shipped out> to work out.
}%
{<expression for computing the absolute page number of the page after
whose shipping-out code shall be carried out>}%
{<code to carry out after the page has been shipped out>%
% Be aware that you cannot use this for adding visible material
% or glue to a page. You can use this only for doing abstract actions
% like calculations or directives like `\thispagestyle{...}`.
}%
以下に最小限の動作例を示します。
この例ではフックが 使用shipout/after
されています。\changes
ltshipout.dtxこのフックは2021年1月8日に追加されました。
したがって、この例は2021年1月8日以前のLaTeXリリースでは間違いなく機能しませんが、そのような以前のLaTeXリリースではエラーメッセージは表示されません。
これは、使用方法が実装されていないという意味で存在しないフックにコードを割り当てても、警告やエラーメッセージは表示されないためです。この例は、たとえばTeX Live 2022では機能します。したがって、たとえば次のようにコンパイルできます。裏面Overleaf のメニューで TeX Live 2022 が選択されている場合。
\NeedsTeXFormat{LaTeX2e}[2021/01/08]
% (According to \changes-entry in ltshipout.dtx the hook
% shipout/after was added in January 8, 2021.)
\makeatletter
\RequirePackage[abspage]{zref}
\ExplSyntaxOn
%...............................................................................
% Save the value of abspage-counter to a zref-label:
%...............................................................................
\cs_new_protected:Npn \saveabspage #1 {\zref@labelbyprops{#1}{abspage}}
%...............................................................................
% Obtain the saved abspage-counter-value from zref-label if possible, otherwise
% deliver -1:
%...............................................................................
\cs_new_protected:Npn \getabspage #1 {\zref@extractdefault{#1}{abspage}{-1}}
%...............................................................................
% Map over comma-list #1 denoting zref-labels and execute code #2 in case all of
% them are defined, otherwise execute code #3; this is for doing calculations
% with zref-labels which can only be done in case all of them are defined:
%...............................................................................
\cs_new:Npn \CheckWhetherAllZlabelsDefined #1
{
\exp:w
\clist_map_function:nN {#1} \mystuff_checkzlabel:nwnn
\exp_after:wN\exp_end:\use_i:nn
}
\cs_new:Npn \mystuff_checkzlabel:nwnn #1#2 \exp_after:wN\exp_end:\use_i:nn #3#4
{
\int_compare:nNnTF {\getabspage{#1}}={-1}
{#2 \exp_after:wN\exp_end:\use_i:nn {#4}}
{#2 \exp_after:wN\exp_end:\use_i:nn {#3}}{#4}%
}
%...............................................................................
% Map over comma-list denoting zref-labels and generate warning for each
% undefined zref-label:
%...............................................................................
\cs_new_protected:Npn \WarnForUndefinedZlabels #1
{
\clist_map_function:nN {#1}\zref@refused
}
%...............................................................................
% Provide code to execute on background-picture-environment of page whose
% absolute page number is to be specified:
%...............................................................................
\cs_new_protected:Npn \CodeAfterShipoutOfAbsolutePage#1#2#3{
% #1 = comma-list of zref-labels that must exist for the code (#3) to be
% carried out.
% #2 = expression for computing the absolute page number of the page
% after whose shipout the code #3 shall be carried out:
% #3 = code to carry out after shipping out the specified page
\AddToHook{shipout/after}{
\WarnForUndefinedZlabels{#1}
\int_compare:nNnT {\CheckWhetherAllZlabelsDefined{#1}{#2}{-1}}
=
{\value{abspage}}
{#3}
}
}
\ExplSyntaxOff
\makeatother
\documentclass{article}
\usepackage{lipsum}
\pagestyle{headings}
\CodeAfterShipoutOfAbsolutePage{Some ABS label}%
{\getabspage{Some ABS label}-1}%
{\thispagestyle{empty}}%
\begin{document}
\section{Some headings}
\subsection{Some more headings}
\lipsum{1-2}
\begin{figure}
\noindent\rule{\textwidth}{.6\textheight}
\caption{Some figure}\saveabspage{Some ABS label}
\end{figure}
\lipsum{3-18}
\end{document}
(欠点は、最初のページを変更するためにこれを使用できないことです。その前には出荷処理を実行できるページがないため)。