答案1
一个不可避免的tcolorbox
解决方案,提供了很多配置可能性。 的默认移位设置Note:
为1.5cm
,但可以通过选项更改nodeshift=...
\documentclass{article}
\usepackage{blindtext}
\usepackage[most]{tcolorbox}
\makeatletter
\NewDocumentCommand{\mynote}{+O{}+m}{%
\begingroup
\tcbset{%
noteshift/.store in=\mynote@shift,
noteshift=1.5cm
}
\begin{tcolorbox}[nobeforeafter,
enhanced,
sharp corners,
toprule=1pt,
bottomrule=1pt,
leftrule=0pt,
rightrule=0pt,
colback=yellow!20,
#1,
left skip=\mynote@shift,
right skip=\mynote@shift,
overlay={\node[right] (mynotenode) at ([xshift=-\mynote@shift]frame.west) {\textbf{Note:}} ;},
]
#2
\end{tcolorbox}
\endgroup
}
\makeatother
\begin{document}
\blindtext
\mynote{Brontosaurs are thin at one end, thick in the middle and thin again at the other end}
% Exaggerated example
\mynote[noteshift=4cm,colback=green!40]{Brontosaurs are thin at one end, thick in the middle and thin again at the other end}
\end{document}
答案2
这是您所寻找的东西吗?
然后你可以使用新命令 \notte
源自环境quote
:
\documentclass{article}
\usepackage{lipsum}
\newlength{\Lnote}
\newcommand{\notte}[1]
{\addtolength{\leftmargini}{4em}
\settowidth{\Lnote}{\textbf{Note:~}}
\begin{quote}
\rule{\dimexpr\textwidth-2\leftmargini}{1pt}\\
\mbox{}\hspace{-\Lnote}\textbf{Note:~}%
#1\\[-0.5ex]
\rule{\dimexpr\textwidth-2\leftmargini}{1pt}
\end{quote}
\addtolength{\leftmargini}{-4em}}
\begin{document}
\lipsum[3]
\notte{To create a note section like in the picture, use the command \texttt{notte}.}
\lipsum[4]
\notte{Another note}
\end{document}
答案3
tabularx, makecell
和 的解决方案linegoal
:
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage[svgnames, table]{xcolor}
\usepackage{tabularx, makecell, linegoal}
\usepackage{lipsum}% only for example text
\newcommand{\mynote}[1]{\medskip\par\textbf{\small Note}\quad\setlength{\extrarowheight}{2pt}\begin{tabularx}{\linegoal}{X}
\Xhline{1pt}
\rowcolor{WhiteSmoke!80!Lavender}#1 \\
\Xhline{1pt}
\end{tabularx}}
\begin{document}
\sffamily
\lipsum[2]
\mynote{Internal pullup resistors are enabled on the MSP430F20xx to support l\textsuperscript{2}C communication}
\end{document}