1

I have a problem with the rectangular of makeemptybox and the line. I would like to reduce the orizontal dimension like my figure (with the same measure). With my code the rectangular on the left invade the etter (b)

That's my code:

\documentclass[a4paper,12pt]{article}[12pt]
\usepackage[italian]{babel} 
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}

\usepackage{multicol}




\usepackage[a4paper,top=1.0cm,bottom=1.0cm,left=1.0cm,right=1.0cm]{geometry}


\newcommand{\makenonemptybox}[2]{%
\par\nobreak\vspace{\ht\strutbox}\noindent
\fbox{%
\parbox[c][\dimexpr#1-2\fboxsep][t]{\dimexpr\linewidth-2\fboxsep}{
\hrule width \hsize height 0pt
#2
}%
}%
\par\vspace{\ht\strutbox}
}





\begin{document}


\pagestyle{empty}

\begin{enumerate}

\item  \textbf{e1}:


\begin{enumerate}
 \begin{multicols}{2} 
\item 

\makenonemptybox{0.5in}
                   {                   
                  box 1                     
                   }
\enspace\hrulefill                                                                        

\item

\makenonemptybox{0.5in}
                   {                   
                  box 2                     
                   }
\enspace\hrulefill                                                

\end{multicols} 
\end{enumerate}


 \item  \textbf{e2}:

\begin{enumerate} \begin{multicols}{2} \item

 \makenonemptybox{0.5in}
                    {                   
                   box 1                     
                    }
 \enspace\hrulefill                                                                        

 \item 

 \makenonemptybox{0.5in}
                    {                   
                   box 2                     
                    }
\enspace\hrulefill                                                

\end{multicols} 
\end{enumerate}



\end{enumerate}

\end{document}

enter image description here

enter image description here

1 Answer 1

2

You forgot to account for the width of the column separation (\columnsep). You also need to increase the default separation a bit. The following fixes your immediate problem. Note, however, that if you want to have items set in a grid pattern, you should consider using the tasks package, which will simplify the rest of your code.

\documentclass[12pt]{article}
\usepackage[a4paper,top=1.0cm,bottom=1.0cm,left=1.0cm,right=1.0cm]{geometry}
\usepackage{multicol}

\setlength{\columnsep}{.5cm}

\newcommand{\makenonemptybox}[2]{%
  \par\nobreak\vspace{\ht\strutbox}\noindent
  \fbox{%
    \parbox[c][\dimexpr#1-2\fboxsep][t]{\dimexpr\linewidth-\columnsep-2\fboxsep}{
    \hrule width \hsize height 0pt
    #2
    }%
  }%
  \par\vspace{\ht\strutbox}
}

\begin{document}
  \pagestyle{empty}

  \begin{enumerate}

    \item  \textbf{e1}:

    \begin{enumerate}
      \begin{multicols}{2} 
        \item \makenonemptybox{0.5in} {box 1}
          \enspace\hrulefill      
        \item \makenonemptybox{0.5in} {box 2}
          \enspace\hrulefill
      \end{multicols} 
    \end{enumerate}

    \item \textbf{e2}:

    \begin{enumerate}
      \begin{multicols}{2}
        \item \makenonemptybox{0.5in} {box 1}
          \enspace\hrulefill 
        \item \makenonemptybox{0.5in} {box 2}
          \enspace\hrulefill
      \end{multicols} 
    \end{enumerate}
  \end{enumerate}
\end{document}

The result:

enter image description here

1
  • thanks I'll modify my code and I'll let you know ;)
    – ryuk
    Jan 7, 2019 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .