tikz 表中的换行

tikz 表中的换行

我想在 tikz 表中写入的文本中有一个换行符(此处的示例Latex Beamer 中的极简主义块)我有的乳胶代码是:

\documentclass[10pt]{beamer}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{marvosym}
\usepackage{tcolorbox}
\usepackage{tikz}
\newcommand{\minimalisticBoxred}[2]{
\begin{figure}
\centering
\begin{tikzpicture}
\node(example-align)[red,rounded corners,draw,line width=1.5pt,inner sep=5ex](MBoxForm){#2};
\node[anchor=west,fill=white] at (MBoxForm.155) {#1};
\end{tikzpicture}
\end{figure}
}%\minimalisticBox{title}{contents} 
\begin{document}
\begin{frame}
\minimalisticBoxred{Tikz}{Example of text with a line break \\ Want to have a \\ line break here} 
\end{frame}
\end{document}

我遵循了以下几个例子这个问题的答案但还没有起作用。我遗漏了什么?

答案1

添加align=left到我得到的第一个节点

\documentclass[10pt]{beamer}
\usepackage{tikz}
\newcommand{\minimalisticBoxred}[2]{
\begin{figure}
\centering
\begin{tikzpicture}
\node(example-align)[red,rounded corners,draw,line width=1.5pt,inner
sep=5ex,align=left](MBoxForm){#2};
\node[anchor=west,fill=white] at (MBoxForm.155) {#1};
\end{tikzpicture}
\end{figure}
}%\minimalisticBox{title}{contents} 
\begin{document}
\begin{frame}
\minimalisticBoxred{Ti\emph{k}Z}{Example of text with a line break \\ Want to have a \\ line break here} 
\end{frame}
\end{document}

在此处输入图片描述

一般来说,您需要指定对齐方式或text width启用换行符。

您在代码中加载了内容,但没有使用tcolorbox。实际上,我认为这可能是设计盒子的更好方法。

相关内容