将三个小框与文本对齐

将三个小框与文本对齐

我通过此链接在专家的帮助下创建了盒子内的盒子乳胶中一个盒子里面有三个盒子可以吗

现在我很困扰,如何输入命令来将这三个框与没有框的文本水平对齐?

示例输出如下:

样本输出将是

答案1

下面我定义了\UnboxedQuestion,将样式更改为内联,第一个可选参数定义了要用于框的样式:

在此处输入图片描述

默认文本宽度设置为6.0cm(如上所示)。但是,可以通过第二个可选参数进行调整:

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{tikz}
\usepackage{xparse}
\usepackage{enumitem}

\newcommand*{\HorizontalSpacing}{\hfill}% equally spaced boxes
%\newcommand*{\HorizontalSpacing}{\hspace*{2.0cm}}% fixed space boxes

\newlength{\InnerSep}
\setlength{\InnerSep}{0.1cm}

\newcommand{\Boxed}[2][]{%
    % #1 = box draw/fill options
    % #2 = text
    \begin{tikzpicture}[baseline, inner sep=2pt, outer sep=0]
            \node [#1] (Origin) {#2};
            \draw [thick, draw=black, #1] 
                (Origin.south west) rectangle (Origin.north east) ;
    \end{tikzpicture}%
}


\tikzset{Inner Box Style/.style={
    inner sep=2pt, yshift=0.7ex, 
    text width=1ex, minimum height=2ex
    }
}

\NewDocumentCommand{\UnboxedQuestion}{O{} O{6.0cm} m m m m}{%
    % #1 = optional draw options for inner boxes
    % #2 = text of question
    % #3 = choice 1
    % #4 = choice 2
    % #5 = choice 3
    \noindent\parbox[c]{#2}{%
        \begin{enumerate}[series=UnboxedLists, resume=UnboxedLists]%
            \item #3\strut%
        \end{enumerate}%
    }%
    \hfill\hspace*{\InnerSep}\Boxed[Inner Box Style, #1]{}\,#4%
    \HorizontalSpacing\Boxed[Inner Box Style, #1]{}\,#5%
    \HorizontalSpacing\Boxed[Inner Box Style, #1]{}\,#6%
    \hspace*{\InnerSep}\null%
}%

\newcommand{\ShortTitle}{Is this what you are looking for?}
\newcommand{\LongTitle}{Is this what you are looking for? 
    But what happens if the text is much longer?
    Well in that case I guess it should wrap.}

\begin{document}
\UnboxedQuestion
    {Is this what you are looking for?}
    {YES}{NO}{NONE}

\medskip
\UnboxedQuestion[draw=blue, fill=yellow!50]
    {\LongTitle}
    {YES}{NO}{NONE}


\medskip
\UnboxedQuestion
    [solid, draw=blue, fill=orange!50][5.0cm]
    {\LongTitle}
    {YES}{NO}{NONE}

\medskip
\UnboxedQuestion
    [solid, ultra thick, draw=blue, fill=orange!50][7.5cm]
    {\LongTitle}
    {YES}{NO}{NONE}
\end{document}

相关内容