Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I made through creating the boxes inside a box with help of an expert by this link Is three boxes inside a box posibble in latex

Now im being troubled on how will i put into command to align this three boxes together with a text horizontally without a box?

Sample output would be like:

sample output will be

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Below I have defined \UnboxedQuestion, which changes the style to be inline, and the first optional parameter defines the style to be used for the boxes:

enter image description here

The default text width is set to 6.0cm (as shown above). However, this can be adjusted via the second optional parameter:

enter image description here

Code:

\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}
share|improve this answer
    
Sir, This is exactly the form i want but why is it when I add some more text to Is this what you are looking for the 3 boxes went down the line. I somehow want the three small boxes in static. Like the number 2 in the sample output i indicated above :) –  Kayla Nov 25 '12 at 10:33
    
Sir I changed \UnboxedQuestion {Is this what you are looking for?} to \UnboxedQuestion {Is this what you are looking for? e text here text here text here text here text here} See what happens to the three small boxes.. :) –  Kayla Nov 25 '12 at 10:36
    
I updated the solution a few minutes ago, please try the new version and let me know if that solves you problem. If not, please compose a fully compilable MWE including \documentclass and the appropriate packages that illustrates the problem. –  Peter Grill Nov 25 '12 at 10:36
    
Oh,and no need to use "Sir".. Makes me feel old, not that I am not... :-) –  Peter Grill Nov 25 '12 at 10:37
    
I think this will be the solution to my prob. I'll just adjust the spaces. Thanks! –  Kayla Nov 25 '12 at 10:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.