對於給定的某些有意形式的詩歌,如果可以在文本和線條周圍繪製一個框架,那麼它可能會有一定的用處。這與簡單的矩形盒子不同,而是適合所寫線條形狀的形式。
感謝您提供一些提示(如果有)。
微量元素:
\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}