![\sectionmark で adjustbox を使用するにはどうすればよいですか?](https://rvso.com/image/286976/%5Csectionmark%20%E3%81%A7%20adjustbox%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%99%E3%81%8B%3F.png)
\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}