I'm trying to create an environment that makes paragraphs or groups of paragraphs in my text visually distinct from the rest. I just want it to be clear what is the one and what is the other. Ideally adding or removing this environment will not actually move any text on the page (though I could live with some re-wrapping if it changes line widths) and it must never change the order of the text.
\begin{leftbar} (from framed) works visually well, but it messes up \footnote{...}s. Also if I understand correctly leftbar results in a float which can be typeset somewhere out-of-line (which my use can't tolerate) if that is needed to keep it on a single page. I want things to split across pages if needed, just like a \paragraph, \section or an empty environment would.
Example
Just for completeness sake; this repros from more or less exactly what the the second paragraph starts with:
\documentclass{article}
\usepackage{framed}
\begin{document}
\begin{leftbar}
Hello\footnote{to the}
World\footnote{we live in}
\end{leftbar}
\end{document}
The footnote mark shows up but there is no footnote text at the bottom of the page.
If there are no easy options for that, are there any other ways I can highlight a chunk of text that won't adversely affect layout?
I've tried tcolorbox but that pulls the footnotes inside the resulting box. colorbox looks like it can maybe do something useful to me, but I don't see how to apply it to the body of my environment
A few of the things I've tried that don't work and why:
These are just the ones that have been mentioned in answers or comments.
\footnotemark/\footnotetext (without numbers)
- They produce incorrect numbers if more than one is placed in the same context.
- They place the footnotes on the wrong page if the enclosing environment spills over to another page.
...
\begin{leftbar}
Hello\footnotemark
World\footnotemark
\end{leftbar}
\footnotetext{to the}
\footnotetext{we live in}
...
\footnotemark/\footnotetext (with numbers)
They are brittle and can generate incorrect result, even messing up other footnotes without breaking the compile:
...\footnote{First}
\begin{leftbar}
Hello\footnotemark[1]
World\footnotemark[2]
\end{leftbar}
\footnotetext[3]{WTF?!}
\footnotetext[2]{to the}
\footnotetext[1]{we live in}
\footnote{Last}
...
\colorbox{C}{...}
Can't (as far as I can tell) be wrapped around the body of a \newenvironment.
\begin{mdframed}
The mdframed environment places the footnotes inside the resulting box and at the end of it, which can be in the middle of a page and on a different page than the footnote mark is on.

leftbardoesn't produce a float. – Bernard Jan 01 '22 at 09:58leftbar, please always include a complete small test document that shows the problem. – David Carlisle Jan 01 '22 at 12:11leftbar, example added. I guess doing that documents whatusepackageI getleftbarfrom. – BCS Jan 01 '22 at 18:37\savenotes/\spewnoteswould place footnotes on the wrong page when the environment spills across page break.\footnotemark/\footnotetextgets very ugly and brittle when there is more than one footnote. ... Gross. – BCS Jan 01 '22 at 18:50