![圆角矩形内的文字](https://linux22.com/image/456908/%E5%9C%86%E8%A7%92%E7%9F%A9%E5%BD%A2%E5%86%85%E7%9A%84%E6%96%87%E5%AD%97.png)
我的代码:
\documentclass{article}
\usepackage{tikzpagenodes}
\begin{document}
\begin{tikzpicture}
\node (example-textwidth-3) [draw, align=center, text width=16cm, rounded corners=4]{\vfill \textbf{\LARGE Subject Title \vfill}\\ \vspace{0.5cm} \Large This is a long title. This is a long title. This is a long title. This is a long title. This is a long title. This is a long title. \linebreak};
\end{tikzpicture}
\end{document}
我想纠正错误,并将其居中显示。
答案1
像这样?
(红线表示页面布局)
您的框比文本块的宽度宽得多,因此它突出了右边框。在上图中,框的宽度限制为文本的宽度:
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{tikz}
\begin{document}
\noindent%
\begin{tikzpicture}
\node (example-textwidth-3) [draw, rounded corners,
text width=\linewidth-24pt, % <---
align=flush center,
inner sep=12 pt]%
{\textbf{\LARGE Subject Title}\par
\vspace{5mm}
\Large
This is a long title. This is a long title. This is a long title. This is a long title. This is a long title. This is a long title};
\end{tikzpicture}
\end{document}