如何制作带有背景颜色的文本框架

如何制作带有背景颜色的文本框架

我试图实现这一点,但无法实现,因此非常感谢任何帮助。 在此处输入图片描述

这是我尝试过的代码:

\begin{figure}[h]

\renewcommand{\arraystretch}{1.5}

\centering

\scalebox{.8}

{
    \begin{tabular}{>{\center}p{10cm}}

                \framebox[10cm]{Some text here} \\
                \framebox[10cm]{\{Some text here\}} \\
                \framebox[10cm]{Some text here} \\
                \framebox[10cm]{Some text here} \\
                \framebox[10cm]{Some text here} \\
                %\framebox[8cm]{\colorbox{BlueGreen}{Some text here}} \\
                %\colorbox{BurntOrange}{Some text here} \\

    \end{tabular}
}
\caption{User registration phase of proposed scheme}
\label{fig:User registration phase}
\end{figure}

答案1

在该包的帮助下tcolorbox

在此处输入图片描述

\documentclass{article}
\usepackage[dvipsnames]{xcolor}

\usepackage{tcolorbox}
\newtcolorbox{mybox}[2]{
    arc=0pt,
    boxrule=#2pt,
    colback=#1,
    width=10cm,
    halign=center,
}

\begin{document}

\begin{figure}
\centering
  \begin{mybox}{green}{0}
     Some text
  \end{mybox}
  \begin{mybox}{white}{1}
     some text
  \end{mybox}
  \begin{mybox}{yellow}{0}
     some text
  \end{mybox}
  \begin{mybox}{white}{1}
     some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text
  \end{mybox}
\caption{User registration phase of proposed scheme}
\label{fig:User registration phase}
\end{figure}

\end{document}

相关内容