创建注释部分

创建注释部分

我想知道如何创建如图所示的带有两行的注释部分。如果我可以像 一样在 LaTeX 中使用它作为命令,我会很高兴\note{some text}

在此处输入图片描述

提前致谢。

答案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}

在此处输入图片描述

答案4

我建议你尝试脚注。应该对文本中的注释指向哪段文本(如参考文献)有一个了解。以下是示例代码:

\documentclass{article}
\begin{document}
Hello World
This is text with a note.\footnote{This is the note text.
Here it is at the bottom of the page.}
\end{document}  

在此处输入图片描述

相关内容