我的代码:
\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}