Consider the following example, which contains the %
-sign inbetween \only<2>{ .... my macro .... }
and the subsequent minipage
. If I leave it out, the spacing of the whole frame gets screwed. I understand what the %
does and why it needs to be there. But I really would like to leave it out, because it would require to think about it and it would complicate the structure and organisation of my document. For that reason I'd like to keep the blank line.
Example in context of beamer: I'm using my custom environment to place tikz-objects somewhere on my frame and I'd like to place these code-snippets wherever I want within the frame environment, without thinking about what comes before or after, because actually the tikzpicture shouldn't effect any other content on the frame as it used as overlay. However the simple writing of the command does.
How can I make the inserting of these code snippets independent of the %
-sign? Or is there a way to already include it inside the macro or environment?
\documentclass{beamer}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{kantlipsum}
\usepackage{environ}
\NewEnviron{tikzannotation}{%
\begin{tikzpicture}[overlay, remember picture, shift={(current page.south west)}]
\BODY
\end{tikzpicture}%
}
\begin{document}
\begin{frame}
\only<2>{%
\begin{tikzannotation}
\node[circle,fill = cyan, minimum width = 1.4cm, align=center,opacity=0.8,
text opacity = 1, font={\scriptsize},inner sep = 1pt
] at (11.2,7.2) {\SI{100}{\percent}\\real!};
\end{tikzannotation}%
}
% <----- this is important - but I want to leave it out!
\begin{minipage}[t]{\textwidth}
\kant[10]
\end{minipage}
\end{frame}
\end{document}
I hope this question does not appear to stupid. If I know what is the reason, I can fix it. But I'm worried about the cases where I don't realize.
Comment
I'm aware that I could just leave out the blank line, but I want exactly that to make the code more readible. In a case where the reason for a blank line is to start a new paragraph I see the point. But in my case here it starts a new paragraph after nothing.
I basically wondered if there is a command like \pleaseIgnoreAllFollowingBlankLinesUntilTheNextGroup
I could include inside my macro/environment. For example after all \begin{...}
it does not matter if there are blank lines or not. Is there no way to adapt this behaviour?
Further idea
As mentioned by David Carlisle, the problem is is caused by the creation of a new paragraph. So \let\par\relax
could do the trick, as long as it happens inside a group. Is it advisable? Is there a way to get inside the environment definition?
\only<2>{%
\let\par\relax%
\begin{tikzannotation}%
\node[circle,fill = cyan, minimum width = 1.4cm, align=center,opacity=0.8,
text opacity = 1, font={\scriptsize},inner sep = 1pt
] at (11.2,7.2) {\SI{100}{\percent}\\real!};
\end{tikzannotation}%
}
\ignorespaces
and\ignorespacesafterend
perhaps? But I rarely use them, I am pretty fine with%
%
as long as you also leave out the blank line. A blank line is a paragraph break and implies vertical spacing,%
within the environment is not commenting a blank line (i.e. paragraph) but an end of line (i.e. space).