pdflatex 中的标题图例(虚线、链线、虚线……)

pdflatex 中的标题图例(虚线、链线、虚线……)

我的目标是在 Latex 的标题中添加图例。该图例将包括实线、虚线、链线等符号。但是,我希望在不“弄乱” IEEEtran 文档类的字体的情况下完成此操作。

我的第一个想法是使用 pstricks 包:

\documentclass[journal]{IEEEtran}
\usepackage{pstricks}
\newbox{\full}
\savebox{\full}{(
\begin{pspicture}(0,0)(0.6,0)
\psline[linewidth=0.04,linecolor=black](0,0.1)(0.6,0.1)
\end{pspicture})}

\newbox{\dotted}
\savebox{\dotted}{
    (\begin{pspicture}(0,0)(0.6,0)
    \psline\[linestyle=dashed,dash=1pt 2pt,linewidth=0.04,linecolor=black\](0,0.1)(0.6,0.1)
    \end{pspicture})}
\newbox{\dashed}
\savebox{\dashed}{
    (\begin{pspicture}(0,0)(0.6,0)
    \psline\[linewidth=0.04,linecolor=black\](0,0.1)(0.15,0.1)
    \psline\[linewidth=0.04,linecolor=black\](0.2,0.1)(0.4,0.1)
    \psline\[linewidth=0.04,linecolor=black\](0.45,0.1)(0.6,0.1)
    \end{pspicture})}

\newbox{\chain}
\savebox{\chain}{
    (\begin{pspicture}(0,0)(0.6,0)
    \psline\[linewidth=0.04,linecolor=black\](0,0.1)(0.15,0.1)
    \psline\[linewidth=0.04,linestyle=dashed,dash=1pt 2pt,linecolor=black\](0.2,0.1)(0.4,0.1)
    \psline\[linewidth=0.04,linecolor=black\](0.45,0.1)(0.6,0.1)
    \end{pspicture})}
\begin{document}
\title{Title}
\author{Authors}
\maketitle
\begin{abstract}
LOREM IPSUM.
\end{abstract}
\begin{IEEEkeywords}
Keywords.
\end{IEEEkeywords}

\section{Introduction}
TEST: Dashed: \usebox{\dashed}, Chain: \usebox{\chain}, full: \usebox{\full}, dotted: \usebox{\dotted}.
\end{document}

如果使用 xelatex 进行编译,则会产生以下结果:

在此处输入图片描述

但是,IEEEtran 文档类的字体被改变了。理想情况下,我想创建这些图例符号或类似符号,而不改变文档类的字体(可能只有使用 pdflatex 编译器才有可能?),我正在寻找一种方法来做到这一点。

答案1

一种可能性是使用 tikz;用 pdflatex、xelatex 或 lualatex 进行编译。

在此处输入图片描述

\documentclass[journal]{IEEEtran}
\usepackage{tikz}
\DeclareRobustCommand\full  {\tikz[baseline=-0.6ex]\draw[thick] (0,0)--(0.5,0);}
\DeclareRobustCommand\dotted{\tikz[baseline=-0.6ex]\draw[thick,dotted] (0,0)--(0.54,0);}
\DeclareRobustCommand\dashed{\tikz[baseline=-0.6ex]\draw[thick,dashed] (0,0)--(0.54,0);}
\DeclareRobustCommand\chain {\tikz[baseline=-0.6ex]\draw[thick,dash dot dot] (0,0)--(0.5,0);}
\begin{document}
\title{Title}
\author{Authors}
\maketitle
\begin{abstract}
LOREM IPSUM.
\end{abstract}
\begin{IEEEkeywords}
Keywords.
\end{IEEEkeywords}

\listoffigures

\section{Introduction}
TEST: Dashed (\dashed), chain (\chain), full (\full), dotted (\dotted).
\begin{figure}
\includegraphics[width=4cm]{example-image}
\caption{\full, \dashed, \chain, and \dotted}
\end{figure}
\end{document}

相关内容