1

Previously I got help to insert images in my beamer slides here: Place image in background layer defined in frame. Now, I am trying to find some way to make sure the text does not cross the slanted white line in the background, without manually inserting linebreaks. Ideally the result should look something like this

enter image description here

This was done using the shapepar package and guessing the correct shape

\newcommand{\myparshape}{
{0}
{0}b{0}\\ 
{0}t{0}{7}\\ 
{4}t{0}{5}\\
{4}e{4} 
}

\newcommand{\diagonalText}[1]{% \begin{tikzpicture} \node[anchor=west,xshift=-1cm] at (2.5,2.5) {\begin{minipage}{0.5\textwidth} \Shapepar{\myparshape} #1 \end{minipage} }; \end{tikzpicture} }

while the solution looks good in the picture above it fails for smaller or larger chunks of text

enter image description here

It also looks strange when there is not enough text. Ideally it should fill out a line before moving to the next.

enter image description here

Questions

  • Is there a semi-automatic way to add a command that restricts the text in such a way that it does not cross the white line in the images above? (The solution does not have to use the parshape package, I only used it as it got the the closest to a "working" solution the fastest)
  • Can this be made to work with lists (enumerate / itemize) as well?

EDIT The new code solves the problem with plain text, but it changes the fontsize. In addition, it still has the same inherent problem as my original attempt, it does not work with lists.

uit-background-titlepage.png

enter image description here

NEW Code

\documentclass[english,aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{graphicx,xcolor}

%Global Background must be put in preamble \usebackgroundtemplate% {% \includegraphics[width=\paperwidth,height=\paperheight]{uit-background-titlepage.png}% }

\definecolor{blue}{HTML}{007396} \colorlet{green}{green!50!black} \definecolor{cyan}{HTML}{59BEC9}

\setbeamercolor{itemize item}{fg=cyan} \setbeamercolor{frametitle}{fg=cyan} \setbeamercolor{normal text}{fg=white} \usebeamercolor*{normal text}

\usepackage{lipsum} \usepackage{shapepar,tikz} \usetikzlibrary{calc,fit,intersections}

\def\shapeparnodeaccuracy{2} \newcommand\shapeparnode[6][]{ % 6 parameters: % style for node (default:empty), % h margin, v margin, left path, right path, text (just one paragraph!)

% name left and right paths and compute there bounding boxes \begin{scope}[local bounding box=leftbb] \path[name path global=left,xshift=#2] #4; \end{scope} \nodeinner ysep=-#3,inner xsep=0pt,fit=(leftbb){}; \begin{scope}[local bounding box=rightbb] \path[name path global=right,xshift=-#2] #5; \end{scope} \nodeinner ysep=-#3,inner xsep=0pt,fit=(rightbb){};

% global bounding box \path let \p1=(leftbb.north west), \p2=(leftbb.south west), \p3=(rightbb.north east), \p4=(rightbb.south east) in \pgfextra{ \pgfmathsetmacro{\ymin}{(\y1 < \y3) ? \y1 : \y3} \pgfmathsetmacro{\ymax}{(\y2 > \y4) ? \y2 : \y4} \typeout{ymin \ymin} \typeout{ymax \ymax} } nodeinner sep=0,fit={(\x1,\ymin pt)(\x3,\ymax pt)}{};

% compute nb steps \path let \p1=(mybb.north), \p2=(mybb.south) in \pgfextra{ \pgfmathsetmacro{\fnthght}{1em/\shapeparnodeaccuracy} \pgfmathtruncatemacro{\nbsteps}{(\y1-\y2)/\fnthght} \xdef\nbsteps{\nbsteps} \typeout{nb steps \nbsteps} };

% horizontal references \path (mybb.north) -- (mybb.south) \foreach \cnt in {0,1,...,\nbsteps}{ \pgfextra{\pgfmathsetmacro{\pos}{\cnt/\nbsteps}} coordinate[pos=\pos] (ref \cnt) };

% left and right boundaries coordinates \foreach \cnt in {0,1,...,\nbsteps}{ % an horizontal line from left to right \path[name path=ltor] (mybb.west |- ref \cnt) -- (mybb.east |- ref \cnt); % same line from right to left \path[name path=rtol] (mybb.east |- ref \cnt) -- (mybb.west |- ref \cnt); % left boundary \path[name intersections={of=rtol and left,by={l \cnt},sort by=rtol}]; % right boundary \path[name intersections={of=ltor and right,by={r \cnt},sort by=ltor}]; } % start point (and initial value of boundshape) \path let \p1=(l 0) in \pgfextra{ \pgfmathsetmacro{\xstart}{\x1} \xdef\boundshape{{0}{0}b{\xstart}} \xdef\xmin{\xstart} \xdef\xmax{\xstart} };

% top and bottom \path let \p1=(l 0), \p2=(l \nbsteps) in \pgfextra{ \pgfmathsetmacro{\ystart}{\y1}\xdef\ystart{\ystart} \pgfmathsetmacro{\yending}{\y2}\xdef\yending{\yending} }; % incremental definition of boundshape \foreach \cnt in {0,1,...,\nbsteps}{ \path let \p1=(l \cnt), \p2=(r \cnt) in \pgfextra{ \pgfmathsetmacro{\start}{\x1} \pgfmathsetmacro{\len}{\x2-\x1} \pgfmathsetmacro{\ypos}{\cnt/\nbsteps*(\ystart - \yending)} {\let\=\relax \xdef\boundshape{\boundshape\{\ypos}t{\start}{\len}}} \pgfmathsetmacro{\xmin}{(\xmin < \start) ? \xmin : \start} \xdef\xmin{\xmin} \pgfmathsetmacro{\xmax}{(\xmax > \start + \len) ? \xmax : \start + \len} \xdef\xmax{\xmax} }; } % draw the node with text in a shapepar \pgfmathsetmacro{\ymax}{\ystart - \yending} {\let\=\relax \xdef\boundshape{\boundshape\{\ymax}e{0}}} \node[#1,text width=\xmax pt - \xmin pt,align=flush left, anchor=north west,inner sep=0] at (mybb.north west -| \xmin pt,0) {\Shapepar[1pt]{\boundshape}#6\par}; }

% This defines the diagonal text (looking for a better solution) \newcommand{\myparshape}{ {0} {0}b{0}\ {0}t{0}{7}\ {4}t{0}{5}\ {4}e{4} }

\newcommand{\diagonalText}[1]{% \begin{tikzpicture} \node[anchor=west,xshift=-1cm] at (2.5,2.5) {\begin{minipage}{0.5\textwidth} \Shapepar{\myparshape} #1 \end{minipage} }; \end{tikzpicture} }

\newcommand{\diagonalTextImproved}[2][]{% \begin{tikzpicture} \begin{scope} % second example (0.5855,0) -- (0.833,1) \small \def\pathone{(0,0) -- (0,-10)}% \def\pathtwo{(0.74685\paperwidth,0) -- (0.49\paperwidth,-10)}% \shapeparnode[#1] {0em}{1em}{\pathone}{\pathtwo}{#2}% %\draw[dotted,black] \pathone; %\draw[thick,red] \pathtwo; \end{scope} \end{tikzpicture} }

\begin{document}

\begin{frame}{Introduction} \begin{itemize} \item \lipsum[75] \item \lipsum[66] \end{itemize} \end{frame}

\begin{frame}{Introduction} \diagonalText{\lipsum[1]} \end{frame}

\begin{frame}{Introduction} \diagonalTextImproved{\lipsum[1]} \end{frame}

\begin{frame}{Introduction} \diagonalTextImproved{\lipsum[1]\lipsum[66]} \end{frame}

\begin{frame}{Introduction} \diagonalTextImproved{\lipsum[66]} \end{frame}

\end{document}

OLD Code

\documentclass[english,aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{graphicx,xcolor}

%Global Background must be put in preamble \usebackgroundtemplate% {% \includegraphics[width=\paperwidth,height=\paperheight]{uit-background-titlepage.png}% }

\definecolor{blue}{HTML}{007396} \colorlet{green}{green!50!black} \definecolor{cyan}{HTML}{59BEC9}

\setbeamercolor{itemize item}{fg=cyan} \setbeamercolor{frametitle}{fg=cyan} \setbeamercolor{normal text}{fg=white} \usebeamercolor*{normal text}

\usepackage{lipsum} \usepackage{shapepar,tikz}

% This defines the diagonal text (looking for a better solution) \newcommand{\myparshape}{ {0} {0}b{0}\ {0}t{0}{7}\ {4}t{0}{5}\ {4}e{4} }

\newcommand{\diagonalText}[1]{% \begin{tikzpicture} \node[anchor=west,xshift=-1cm] at (2.5,2.5) {\begin{minipage}{0.5\textwidth} \Shapepar{\myparshape} #1 \end{minipage} }; \end{tikzpicture} }

\begin{document}

% Can one avoid that the text in this list extends beyond the white line? \begin{frame}{Introduction} \begin{itemize} \item \lipsum[75] \item \lipsum[66] \end{itemize} \end{frame}

% Good fit between the text and the line \begin{frame}{Introduction} \diagonalText{\lipsum[1]} \end{frame}

% Too little text, should fill a line before extending \begin{frame}{Introduction} \diagonalText{\lipsum[75]} \end{frame}

% Too much text for the parshape commands breaks the line again \begin{frame}{Introduction} \diagonalText{\lipsum[1]\lipsum[66]} \end{frame}

\end{document}

N3buchadnezzar
  • 11,348
  • 7
  • 55
  • 114
  • It appears to me that you are looking for this genius answer. And this question appears to be closely related, ironically it has a very similar shape. –  Apr 11 '20 at 00:35
  • @Schrödinger'scat Thanks, using the links provided I was able to construct a trapezoid and fill it with text. However, the font seems to be too small compared to the "normal text" and using large makes it too big. https://i.imgur.com/TBqB3PM.png (the bottom image is the automatic tikz solution and the top image is the default fontsize).Is there a way to tell the tikznode to simply use the font and fontsize already selected? – N3buchadnezzar Apr 11 '20 at 11:45
  • Could you perhaps either edit the question to show what you have done (or ask a new question with that content that will be seen by more users)? –  Apr 11 '20 at 13:44
  • @Schrödinger'scat I updated the question now. Reason why I did not post my code as an answer, is the problem with fontsize, but also that the new code does not work with lists. (Which was one of the things I wanted to fix) – N3buchadnezzar Apr 11 '20 at 17:10

0 Answers0