moderncv のセクション見出しの TikZ

moderncv のセクション見出しの TikZ

私はかなりランダムに実験していて、セクションの見出しにいくつかの TikZ を挿入することを考えました。

ではarticle、この

\documentclass{article}
\usepackage{tikz}
\newcommand{\my}{\tikz\draw (0,0) circle (5pt);}

\begin{document}
\section{Introduction \protect\my}
\end{document}

動作します。

moderncvしかし、これを使うと

\documentclass{moderncv}
\usepackage{tikz}
\moderncvstyle{classic}
\newcommand{\my}{\tikz\draw (0,0) circle (5pt);}

\begin{document}
\section{Introduction \protect\my}
\end{document}

動作しません。

なぜ?

答え1

hyperrefこれはとの間に矛盾がありtikzmoderncvは をロードしますhyperref

解決策としては、 を使用し\texorpdfstringてコマンドを定義することです。

このようなもの:

\texorpdfstring{tikz code}{alternative (empty)}

MWE は次のようになります。

\documentclass{moderncv}
\usepackage{tikz}
\moderncvstyle{classic}
\newcommand{\my}{\texorpdfstring{\tikz\draw (0,0) circle (5pt);}{}}
\firstname{John}
\familyname{Doe}

\begin{document}
\section{Introduction \protect\my}
\end{document}

関連情報