对于一些有意为之的诗歌形式,如果能在文本和诗行周围画一个框架,可能会有一定的用处。这不像一个简单的矩形框,而是适合诗行的形状。
如果有的话,感谢您提供一些提示。
梅威瑟:
\documentclass{report}
\begin{document}
\centering
This is\\
an example \\
how it can be\\
and should\\
appear.
\vspace*{\baselineskip}
Without \\
the lines \\
around it. Can you\\
imagine the\\
lines?
\end{document}
文本周围的线条需要想象。有没有方法或包可以将线条绘制得紧贴文本边框。Not
一个矩形框!
初看tikz
软件包,下面的代码似乎可以解决问题,但似乎还不令人满意。原因:外线和内线之间的分隔不够。我试过了,inner sep=5mm
但没有效果(未包括在下面的代码中)。
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\centering
\tikzmark{A} \qquad \tikzmark{N}\\
\tikzmark{B} This is \tikzmark{M}\\
\tikzmark{C} an example \tikzmark{L} \\
\tikzmark{D} how it can be \tikzmark{K}\\
\tikzmark{E} and should \tikzmark{J}\\
\tikzmark{F} appear. \tikzmark{I}\\
\tikzmark{G} \qquad \tikzmark{H}
\tikz[remember picture] \draw[overlay,thick,rounded corners=6pt] (pic cs:A) -- (pic cs:B) -- (pic cs:C) -- (pic cs:D) -- (pic cs:E) -- (pic cs:F) -- (pic cs:G) -- (pic cs:H) -- (pic cs:I) -- (pic cs:J) -- (pic cs:K) -- (pic cs:L) -- (pic cs:M) -- (pic cs:N) -- cycle;
\vspace*{\baselineskip}
\tikzmark{a} \qquad \tikzmark{n}\\
\tikzmark{b} Without \tikzmark{m}\\
\tikzmark{c} the lines \tikzmark{l}\\
\tikzmark{d} around it. Can you \tikzmark{k}\\
\tikzmark{e} imagine the \tikzmark{j}\\
\tikzmark{f} lines? \tikzmark{i}\\
\tikzmark{g} \qquad \tikzmark{h}
\tikz[remember picture] \draw[overlay,thick,rounded corners=6pt] (pic cs:a) -- (pic cs:b) -- (pic cs:c) -- (pic cs:d) -- (pic cs:e) -- (pic cs:f) -- (pic cs:g) -- (pic cs:h) -- (pic cs:i) -- (pic cs:j) -- (pic cs:k) -- (pic cs:l) -- (pic cs:m) -- (pic cs:n) -- cycle;
\end{document}
答案1
\draw plot[smooth cycle, thick] coordinates { ... }
可能会产生更好的结果,同时将\tikzmark
sa 稍微向上移动。tension=...
您可能会得到一些有趣的、可能不太可预见的效果。
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\newcommand\ml[3]{% marked line
\raisebox{0.5ex}[0ex][0ex]{\tikzmark{#1}}\quad
#2\quad
\raisebox{0.5ex}[0ex][0ex]{\tikzmark{#3}}%
}
\begin{document}
\begin{center}
\ml A{}N\\
\ml B{This is}M\\
\ml C{an example}L\\
\ml D{how it can be}K\\
\ml E{and should}J\\
\ml F{appear.}I\\
\ml G{}H
\end{center}
\tikz[remember picture,overlay] \draw plot[smooth cycle, thick]
coordinates {(pic cs:A) (pic cs:B) (pic cs:C) (pic cs:D) (pic cs:E)
(pic cs:F) (pic cs:G) (pic cs:H) (pic cs:I) (pic cs:J) (pic cs:K)
(pic cs:L) (pic cs:M) (pic cs:N)};
\begin{center}
\ml a{}n\\
\ml b{Without}m\\
\ml c{the lines}l\\
\ml d{around it. Can you}k\\
\ml e{imagine the}j\\
\ml f{lines?}i\\
\ml g{}h
\end{center}
\tikz[remember picture,overlay] \draw plot[smooth cycle, thick]
coordinates {(pic cs:a) (pic cs:b) (pic cs:c) (pic cs:d) (pic cs:e)
(pic cs:f) (pic cs:g) (pic cs:h) (pic cs:i) (pic cs:j) (pic cs:k)
(pic cs:l) (pic cs:m) (pic cs:n)};
\begin{center}
\ml 1{}{14}\\
\ml 2{Without}{13}\\
\ml 3{the lines}{12}\\
\ml 4{around it. Can you}{11}\\
\ml 5{imagine the}{10}\\
\ml 6{lines?}9\\
\ml 7{}8
\end{center}
\tikz[remember picture,overlay] \draw plot[smooth cycle, thick, tension=3]
coordinates {(pic cs:1) (pic cs:2) (pic cs:3) (pic cs:4) (pic cs:5)
(pic cs:6) (pic cs:7) (pic cs:8) (pic cs:9) (pic cs:10) (pic cs:11)
(pic cs:12) (pic cs:13) (pic cs:14)};
\end{document}