
這是一個已知問題,tufte-*
如果在環境或es 內部使用,\sidenote
則\marginnote
不會建置。我沒有找到解決方法,而且大多數關於該主題的帖子都表明沒有解決方法。mdframed
tcolorbox
我想要的只是在 .txt 檔案中的某些段落後面放置一個漂亮的灰色背景tufte-handout
。這樣可以嗎沒有 mdframed
或者tcolorbox
?
編輯:最小的例子
\documentclass[nobib,justified]{tufte-handout}
\usepackage{mdframed}
\newmdenv[
linecolor=lightgray,
linewidth=3pt,
leftmargin=0pt,
innerleftmargin=0pt,
rightmargin=0pt,
innerrightmargin=0pt
]{graybox}
\usepackage{lipsum}
\begin{document}
\begin{graybox}
\lipsum[1]
\marginnote{This is a marginnote}
\end{graybox}
\end{document}
無法建構! LaTeX Error: Float(s) lost.
答案1
這是一個可能有的愚蠢的駭客行為很多錯誤,但它似乎適用於遠離分頁符號的短段落。
\documentclass{tufte-handout}
\usepackage{tcolorbox}
\usepackage{blindtext}
\usepackage{environ}
\makeatletter
\NewEnviron{grayground}{%
\noindent\smash{\begin{tcolorbox}[colback=gray!20, colframe=gray!20, oversize, top=0pt, bottom=0pt, left=4pt, right=4pt, box align=top]
\let\sidenote\@gobble
\let\marginnote\@gobble
\color{gray!20}\BODY
\end{tcolorbox}}\par\BODY}
\makeatother
\begin{document}
\begin{grayground}
\blindtext\sidenote{\blindtext}\blindtext
\end{grayground}
\end{document}
解釋
基本思想是首先使用 打印一次文本tcolorbox
,但抑制任何sidenote
或marginnote
,使用與背景顏色相同的文本來隱藏它。
然後我們列印真實的文本,其頂部有活動的旁注和頁邊註釋。
現在,我指望帶有旁注上標的版本和不附旁注上標的版本的測量非常相似,因此,雖然兩個文字不完全相同,但它們應該佔據大致相同的垂直空間,因此您可以獲得遠離這個。
要實現這一點,您只需使用 atcolorbox
進行第一輪列印即可。然後你就粉碎它。
在裡面tcolorbox
你可以letmarginnote
和sidenote
to@gobble
來抑制它們的功能。您可以再次列印相同的文字來完成。
為了使其更易於使用,您可以將所有內容包裝在 Environ 中。
輸出看起來像這樣(圖像稍微過時了;我在程式碼中做了一些調整以使擬合更好一些)。