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}

相關內容