以下是一个例子:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}\centering
\begin{tikzpicture}[extended line/.style={shorten >=-#1,shorten <=-#1}]
\draw [very thick, extended line=1cm] (0,0) -- (0,1);
\end{tikzpicture}
\caption{This is a test caption.}
\end{figure}
\end{document}
及其结果:
我怎样才能将 tikzpicture 移到标题上方?
答案1
这是一个有效的选择吗?
代码
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{
extended line/.style={
to path={
($(\tikztostart)!-#1!(\tikztotarget)$) -- ($(\tikztotarget)!-#1!(\tikztostart)$) \tikztonodes
}
}
}
\begin{document}
\begin{figure}\centering
\begin{tikzpicture}
\draw [very thick] (0,0) to[extended line=1cm] (0,1);
\end{tikzpicture}
\caption{This is a test caption.}
\end{figure}
\end{document}