如何在框架中添加编号框?

如何在框架中添加编号框?

我在不同部分有多个框架框。我需要为这些框架框分配编号,如示例图像中所示。这两个框之间不应有垂直间隙。

梅威瑟:

\documentclass{article}
\usepackage{a4wide}
\usepackage{url}
\usepackage{amsmath,mathtools,amssymb}
% Allow Unicode input (alternatively, you can use XeLaTeX or LuaLaTeX)
\usepackage{framed}
\usepackage{xcolor}
\usepackage{soul}
\usepackage{microtype,xparse,tcolorbox}
\newenvironment{reviewer-comment }{}{}
\tcbuselibrary{skins}
\tcolorboxenvironment{reviewer-comment }{empty,
  left = 1em, top = 1ex, bottom = 1ex,
  borderline west = {2pt} {0pt} {black!20},
}
\ExplSyntaxOn
\NewDocumentEnvironment {response} { +m O{black!20} } {
  \IfValueT {#1} {
    \begin{reviewer-comment~}
      \setlength\parindent{2em}
      \noindent
      \ttfamily #1
    \end{reviewer-comment~}
  }
  \par\noindent\ignorespaces
} { \bigskip\par }

\NewDocumentCommand \Reviewer { m } {
  \section*{Comments~by~Reviewer~#1}
}
\ExplSyntaxOff
\AtBeginDocument{\maketitle\thispagestyle{empty}\noindent}
\newcommand\meta[1]{$\langle\hbox{#1}\rangle$}
\newcommand\PaperTitle[1]{``\textit{#1}''}

\title{Response of comments }
\author{Rudresh \and Somnath }
\date{\today}
\begin{document}

\begin{framed}
{\color{blue} the goal of this article}
\end{framed}

Text description for frame 1.

\begin{framed}
{\color{blue} the goal of this article}
\end{framed}
Text description for frame 2.
\end{document}

在此处输入图片描述

在此处输入图片描述

答案1

我的答案远非完美,也没有使用tcolorbox。我不明白你所说的没有自动计数器是什么意思。这是我的代码:

\documentclass[]{article}

\newcounter{myframC}[section]
\newcommand{\myframe}[2][0.5]{%
    \par\noindent% you might remove this line!
    \refstepcounter{myframC}%
    \begingroup%
    \fboxsep=\dimexpr\fboxsep+\fboxrule\relax%
    \makebox[0pt][l]{\fbox{\makebox[1em][c]{\themyframC}}}%
    \endgroup%
    \fbox{\parbox[t]{#1\textwidth}{\hspace{1.1em} #2}}%
}

\begin{document}
\myframe{I have a framebox. In the framebox, I want to give a number at the
    leftmost top corner. How do I get it using \texttt{\string\newtcolorbox}
    without autocounter.%
}

\end{document}

它允许使用可选参数来\myframe更改宽度,例如\myframe[0.7]{...}用作0.7\textwidth框的宽度。默认值为0.5\textwidth

结果

相关内容