我看见这在某些文本下方添加虚线。但我想知道如何将其向下移动一点并调整其位置,我不知道如何从示例中调整其布局。
我还想知道如何简单地添加“空白行”,基本上在文本中像这样:
Hello this is some text with a ___________ blank line.
我尝试这样做,但似乎不正确并且不起作用:
Hello this is some text with a \thedot{ } blank line.
\newcommand{\thedot}[1]{%
\tikz[baseline=(todotted.base)]{
\node[inner sep=1pt,outer sep=0pt] (todotted) {#1};
\draw[dotted, thick] (todotted.south west) -- (todotted.south east);
}%
}%
我根据当前的答案得出了这一结论:
当我这样做\node[inner sep=1pt,outer sep=0pt,xshift=-2mm]
或\tikz[baseline=2mm]
。仍然不正确。
答案1
使用 tikz 时,只需使用baseline
键,请参阅手册 3.0.1a 的第 124 页。我给线条涂上颜色,使代码更易于阅读。
回复你的最后一条评论:
baseline 在第 124 页的定义如下:
/tikz/baseline=< dimension or coordinate or default >
因此,我们本质上可以使用坐标或维度,但不能同时使用两者。要同时应用两者,transform canvas={yshift=-2pt}
可以按以下方式应用:
\tikz[baseline=(todotted.base)]\path[red, dash dot dot,transform canvas={yshift=-2pt}] node (todotted) {} edge ([xshift=2cm]todotted){};
代码和结果:
\documentclass{article}
\usepackage{tikz}
\begin{document}
Hello this is some text with a \tikz[baseline]\draw[dashed](0,0)--+(1,0); blank line.
Hello this is some text with a \tikz[baseline=-2mm]\draw[red,thick,densely dotted](0,0)--+(1,0); blank line.
Hello this is some text with a \tikz[baseline=1mm]\draw[blue,thick,dotted](0,0)--+(1,0); blank line.
Hello this is some text with a \tikz[baseline=(todotted.base)]\path[cyan, loosely dash dot ] node (todotted) {} edge ([xshift=2cm]todotted){}; blank line.
Hello this is some text with a \tikz[baseline=(todotted.base)]\path[red, dash dot dot,transform canvas={yshift=-2pt}] node (todotted) {} edge ([xshift=2cm]todotted){}; blank line.
\end{document}
答案2
实线:命令是\rule[lift]{width}{thickness}
。
Hello this is some text with a \rule[0pt]{1cm}{.4pt} blank line.
Hello this is some text with a \rule[2pt]{1cm}{.4pt} blank line.
Hello this is some text with a \rule[-2pt]{1cm}{.4pt} blank line.
虚线:使用一个框,我们定义一个以宽度作为参数的新命令。
\documentclass[11pt,a4paper]{report}
\newcommand{\dottedline}[1]{\makebox[#1]{\dotfill}}
\begin{document}
Hello this is some text with a \dottedline{2cm} blank line.
Hello this is some text with a \dottedline{3cm} blank line.
\end{document}
编辑:
您可以更改5mm
值(点之间的距离)和{\Large .}
(用于填充的符号)。
\documentclass[11pt,a4paper]{report}
\makeatletter
\def\mydotsfill{\leavevmode \cleaders \hb@xt@ 5mm{\hss {\Large .}\hss }\hfill \kern \z@}
\newcommand{\dottedline}[1]{\makebox[#1]{\mydotsfill}}
\makeatother
\begin{document}
Hello this is some text with a \dottedline{2cm} blank line.
Hello this is some text with a \dottedline{3cm} blank line.
\end{document}
编辑2:另一个版本,您可以给出一个可选参数,其中的文本将插入到点的上方,并居中。
\documentclass[11pt,a4paper]{report}
\usepackage{graphicx}
\makeatletter
\def\mydotsfill{\leavevmode \cleaders \hb@xt@ 3mm{\hss {\Large .}\hss }\hfill \kern \z@}
\newcommand{\dottedline}[2][]{\makebox[#2]{\mydotsfill\makebox[0pt]{\raisebox{.75ex}{#1}}\mydotsfill}}
\makeatother
\begin{document}
Hello this is some text with a \dottedline[December]{5cm} blank line.
Hello this is some text with a \dottedline{3cm} blank line.
\end{document}