\sectionmark で adjustbox を使用するにはどうすればよいですか?

\sectionmark で adjustbox を使用するにはどうすればよいですか?

\sectionmark で adjustbox を使用したいのですが、動作しません。回避策はありますか?

\documentclass{book}
\usepackage{blindtext}
\usepackage{adjustbox}
\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\sectionmark}[1]{\markright{#1 \adjustbox{valign=t}{\rule{1.5pt}{\baselineskip}} \thesection}}

\fancyhead[RO]{\rightmark}
\fancyhead[LO]{}


\begin{document}

\chapter{An example chapter}

\section{An example section}

\blindtext[25]

\end{document}

答え1

\ruleとはどちらも\adjustbox脆弱なコマンドなので、引数を移動するときには ( の引数は )、\protectそれらの前に を使用する必要があります。\sectionmark

しかし、あなたの願いを叶えるにはもっと良い方法があります。

\documentclass{book}
\usepackage{blindtext}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\sectionmark}[1]{%
  \markright{#1 \strut\vrule width 1.5pt\relax\ \thesection}}

\fancyhead[RO]{\rightmark}
\fancyhead[LO]{}


\begin{document}

\chapter{An example chapter}

\section{An example section}

\blindtext[25]

\end{document}

ここに画像の説明を入力してください

関連情報