Hi guys,
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
Graphics, Figures & Tables ⇒ How to add dashed line in figure caption
How to add dashed line in figure caption
- Attachments
-
- QQ截图20170317173641.png (81.84 KiB) Viewed 18718 times
Last edited by Funny_w on Mon Mar 20, 2017 3:40 pm, edited 1 time in total.
How to add dashed line in figure caption
What exactly did you try for hours? Using TikZ this is pretty straightforward:
Admittedly the manual (
pgfmanual) is rather long, but…
Regards
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
site moderator & package author
How to add dashed line in figure caption
Dear cgnieder,
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:
Is the tikz and the caption environment incompatible? I still be confused...
Anyway, as a freshman, I still learn much from your code.
Yours Sincerely
Funny_w
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: 10315
- Joined: Mon Mar 10, 2008 9:44 pm
How to add dashed line in figure caption
Hello,
the TikZ code in the caption breaks when it's moved to the list of figures. Use a short version without TikZ code:
Stefan
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
LaTeX.org admin
How to add dashed line in figure caption
Dear cgnieder and Stefan Kottwitz,
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.
and the result is almost the same as the figure i uploaded.
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
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