在新的枚举环境中将代码放在项目右侧

在新的枚举环境中将代码放在项目右侧

考虑

在此处输入图片描述

我想在枚举的 tcolorbox 的右侧稍微垂直居中显示 12 个彩色项目符号的字符串。

生成上述图片的代码是

\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{multicol}

\setlength{\columnsep}{1cm}
\usepackage{scalefnt}
\usepackage{xcolor}
\usepackage{amssymb}


% % The colored box that encloses the item number.
\usepackage{tcolorbox}
\newtcbox{\logo}{nobeforeafter, notitle, %sharpcorners,
    colframe=red,
    colback=red!35,
    top=0pt,
    left=0pt,
    right=0pt,
    bottom=0pt,
    fontupper=\sffamily\bfseries,
    tcbox raise base}


% % FANCY ENUMERATE positioning the enumerated colored box above the text.
\newcounter{cenum}
\newcommand\cenumsep{}  
\newenvironment{cenumerate}{%
  \setcounter{cenum}{0}%
  \setlength\parskip\bigskipamount
%  \begin{center}%
}{%
%  \end{center}%
}
\newcommand\citem{%
  \refstepcounter{cenum}%
  \par\cenumsep\logo{\arabic{cenum}}%
  \par\nobreak\vskip-\parskip\medskip\noindent\ignorespaces% \medskip is the distance between label and text, change as needed
}

% NEW SYMBOLS DEFINITION
\newcommand{\red}{\textcolor{red}{{\scalefont{1.0}{\bullet}}}}
\newcommand{\blue}{\textcolor{blue}{{\scalefont{1.0}{\bullet}}}}
  
\begin{document}
\large

 
$\red\blue\red\blue$ $\blue\red\blue\blue$ $\red\red\red\blue$

\begin{multicols}{2}
\begin{cenumerate}
\citem \lipsum[4] 
\end{cenumerate}
\end{multicols}
\end{document}

我曾尝试\citem用替换\citem[$\red\blue\red\blue$ $\blue\red\blue\blue$ $\red\red\red\blue$],并将其放置$\red\blue\red\blue$ $\blue\red\blue\blue$ $\red\red\red\blue$在 的右侧\citem,但这些都没有产生我想要的结果。

问题:我该如何修改上述代码,以便能够按照所述方式,在“花哨”列表的每个枚举项的右侧放置一个由彩色项目符号组成的唯一颜色的二进制字符串?

谢谢。

答案1

稍微向右并垂直居中。

使用新命令\citemx{<bullets patttern>}

是

是

\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{multicol}

\setlength{\columnsep}{1cm}
\usepackage{scalefnt}
\usepackage{xcolor}
\usepackage{amssymb}


% % The colored box that encloses the item number.
\usepackage{tcolorbox}
\newtcbox{\logo}{nobeforeafter, notitle, %sharpcorners,
    colframe=red,
    colback=red!35,
    top=0pt,
    left=0pt,
    right=0pt,
    bottom=0pt,
    fontupper=\sffamily\bfseries,
    tcbox raise base}


% % FANCY ENUMERATE positioning the enumerated colored box above the text.
\newcounter{cenum}
\newcommand\cenumsep{}  
\newenvironment{cenumerate}{%
    \setcounter{cenum}{0}%
    \setlength\parskip\bigskipamount
    %  \begin{center}%
}{%
    %  \end{center}%
}

\newcommand\citemx[1]{% added <<<<<<<<<<<<<<
\refstepcounter{cenum}%
\par\cenumsep\logo{\arabic{cenum}}%
\begin{minipage}{\linewidth} % added <<<<<<<<<<<<<<<<
    \hspace*{20pt}#1  % left/right space
    \vspace*{0.5ex}% vertical adjustment
\end{minipage}
\par\nobreak\vskip-\parskip\medskip\noindent\ignorespaces% \medskip is the distance between label and text, change as needed
}


% NEW SYMBOLS DEFINITION
\newcommand{\red}{\textcolor{red}{{\scalefont{1.0}{\bullet}}}}
\newcommand{\blue}{\textcolor{blue}{{\scalefont{1.0}{\bullet}}}}

\usepackage{showframe}% show the margins <<<<<<<<<<<<<<<<<<<<

\begin{document}
    \large
    
    \begin{multicols}{2}
        \begin{cenumerate}
            \citemx{$\red\blue\red\blue$ $\blue\red\blue\blue$ $\red\red\red\blue$} \lipsum[4] 
            \citemx{$\blue\blue\blue\blue$ $\red\red\red\blue$ $\red\blue\red\red$} \lipsum[1] 
            \citemx{$\blue\red\red\red$ $\blue\blue\red\blue$ $\red\red\red\red$} \lipsum[2] 
            
        \end{cenumerate}
    \end{multicols}
\end{document}

相关内容