# Automatic wrap (line wrap) or manual linebreak in Tikz fancytitle

For a Tikz Fancytitle, how do I either:

1. Get automatic line wrapping, or
2. If 1. is not possible, add manual line breaks (say, using \\)

I used a nested minipage in this example but the question applies to titles on the Tikz box on outer level minipages as well!

Thanks!

Current output:

MWE:

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{url}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{esint}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{amsmath,amssymb}

\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{enumitem}
\makeatletter

\usepackage[utf8]{inputenc}

\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}

\begin{document}

\begin{center}{\huge{\textbf{Notes}}}
\end{center}
\begin{multicols*}{3}

\tikzstyle{mybox} = [draw=black, fill=white, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=10pt]
\tikzstyle{fancytitle} =[fill=black, text=white, font=\bfseries]

%------------ Box1 ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\small
\begin{minipage}{0.3\textwidth}

%------------ Inner Box ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\small
\begin{minipage}{0.3\textwidth}
\end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {This is a really long title.\With a second sentence. And another sentence. And one more.};
\end{tikzpicture}

\end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {Box 1};
\end{tikzpicture}

\end{multicols*}
\end{document}

• You should sort the packages and also only put those packages in your MWE that are really needed. Apart from that, load some packages twice (such as amsmath) and you should load hyperref last. To your concrete question: Since you place the text inside a \href macro, it will be a bit more difficult to put line breaks here. Are these \href commands necessary? Jul 13 at 17:17
• Try {\parbox{\columnwidth-30pt}{This is a really .... Jul 13 at 18:48
• @JasperHabicht Yes, \href{} is definitely not necessary. I accidentally left it in there. I edited and removed it. I’ve also updated the package list to be more compact.
– puf
Jul 13 at 19:08
• @SimonDispa I’ve removed the \href{}. The \parbox on the base sentence only, does not seem to work. See: imgur.com/a/nhbdwLW
– puf
Jul 13 at 19:16

If don't use these \href macros inside the nodes, which would prevent line breaking, you can use the align option together with manual line breaking using \\ like so (I removed unnessesary packages and optimized the order of the packages):

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[landscape]{geometry}
\usepackage{multicol}
\usepackage{tikz}

\parindent0pt
\parskip2pt

\usepackage{fourier}
\usepackage{hyperref}

\begin{document}

\begin{center}{\huge{\textbf{Notes}}}
\end{center}
\begin{multicols*}{3}

\tikzset{mybox/.style={draw=black, fill=white, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=10pt},
fancytitle/.style={fill=black, text=white, font=\bfseries}
}

%------------ Title ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\small
\begin{minipage}{0.3\textwidth}

%------------ Title ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\small
\begin{minipage}{0.3\textwidth}
\end{minipage}
};
\node[fancytitle, right=10pt, align=left] at (box.north west) {This is a really long title. With a second sentence. \\ And another sentence. And one more.};
\end{tikzpicture}

\end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {Box 1};
\end{tikzpicture}

\end{multicols*}
\end{document}


You can also use the option text width (text width=8cm for example) for automatic line breaking, but then the node would always have the same width, regardless of the length of the text inside.

• Thank you! Both options you gave will be perfect. I may use the latter since I don’t mind the node always having the same width (it will be filled with text always).
– puf
Jul 14 at 2:21