Graphics, Figures & Tables ⇒ How to add dashed line in figure caption
How to add dashed line in figure caption
How to add various dashed line in figure caption in Latex like the figure attached? I have tried for hours but not succeed.
Funny_w
- Attachments
-
- QQ截图20170317173641.png (81.84 KiB) Viewed 19351 times
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
How to add dashed line in figure caption
Code: Select all
\documentclass{article}
\usepackage{tikz,siunitx}
\begin{document}
Receiver distances
\tikz[baseline]{\draw[thick] (0,.5ex)--++(.5,0) ;}~\SI{.1}{\meter},
\tikz[baseline]{\draw[dashed] (0,.5ex)--++(.5,0) ;}~\SI{.5}{\meter},
\tikz[baseline]{\draw[densely dashed] (0,.5ex)--++(.5,0) ;}~\SI{1}{\meter},
\tikz[baseline]{\draw[dash dot] (0,.5ex)--++(.5,0) ;}~\SI{2}{\meter},
\tikz[baseline]{\draw[dash dot dot] (0,.5ex)--++(.5,0) ;}~\SI{5}{\meter},
\tikz[baseline]{\draw (0,.5ex)--++(.5,0) ;}~\SI{100}{\meter}
(after ...)
\end{document}

Regards
How to add dashed line in figure caption
Yes, I did try it for a long time but still did not solve this problem.
Your code works well in the document environment. But it does not work in the caption environment even use the command \protect. In the pgfmanual a case was listed like this:
Code: Select all
\begin{figure}
\beginpgfgraphicnamed{graphic-of-flat-world}
\begin{tikzpicture}
\fill (0,0) circle (1cm);
\end{tikzpicture}
\endpgfgraphicnamed
\caption{The flat world.}
\label{fig1}
\end{figure}
Anyway, as a freshman, I still learn much from your code.
Yours Sincerely
Funny_w
- Stefan Kottwitz
- Site Admin
- Posts: 10371
- Joined: Mon Mar 10, 2008 9:44 pm
How to add dashed line in figure caption
the TikZ code in the caption breaks when it's moved to the list of figures. Use a short version without TikZ code:
\caption[optional short text]{text with TikZ}
Stefan
How to add dashed line in figure caption
Thanks to your warm reply!
I realized the key point of this problem, in the caption of figure environment, both of the two commands should be add by a /protect.
So the final code based cgnieder' is followed.
Code: Select all
\begin{figure*}[!htb]
\begin{center}
\includegraphics[width=0.4\paperwidth]{figures/4_13.jpg}
\end{center}
\caption{ \label{fig:4_13}Effect of receiver arc ...eiver distances
\protect\tikz[baseline]{\protect\draw[line width=1mm] (0,.8ex)--++(1,0) ;}~\SI{.1}{\meter},
\protect\tikz[baseline]{\protect\draw[line width=0.5mm,loosely dashed] (0,.8ex)--++(1,0) ;}~\SI{.5}{\meter},
\protect\tikz[baseline]{\protect\draw[line width=0.5mm,densely dashed] (0,.8ex)--++(1,0);}~\SI{1}{\meter},
\protect\tikz[baseline]{\protect\draw[line width=0.5mm,dash dot] (0,.8ex)--++(1,0) ;}~\SI{2}{\meter},
\protect\tikz[baseline]{\protect\draw[line width=0.5mm,dash dot dot] (0,.8ex)--++(1,0) ;}~\SI{5}{\meter},
\protect\tikz[baseline]{\protect\draw[line width=0.5mm] (0,.8ex)--++(1,0) ;}~\SI{100}{\meter} (after Hargreaves et al.7). }
\end{figure*}
Finally, thanks to you both and the community. You are the first ones when I meet a problem and seek the help from.
Sincerely
Funny_w