[Tex/LaTex] Why the checklist box was put on the left

boxes

I just create a simple check list following the way described here: How do I generate a check-list?, My code is below:

\documentclass[a4paper,notitlepage]{article}
\usepackage[]{ctex}
\setCJKmainfont{SimSun}
\usepackage{graphicx}
\usepackage[twocolumn]{geometry}
\usepackage{amssymb}
\usepackage{array}
\newcounter{rowno}
\setcounter{rowno}{0}
\usepackage[export]{adjustbox}  % draw frame of the image
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm,headheight=1cm,headsep=1cm,footskip=1cm}


\usepackage{wasysym}     

\setlength{\marginparwidth}{1.2in}
\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{\-\oldmarginpar[\raggedleft #1]%
{\raggedright #1}}    

\newenvironment{checklist}{%
  \begin{list}{}{}% whatever you want the list to be
  \let\olditem\item
  \renewcommand\item{\olditem -- \marginpar{$\Box$} }
  \newcommand\checkeditem{\olditem -- \marginpar{$\CheckedBox$} }
}{%
  \end{list}
}   

\begin{document}
\begin{checklist}
  \checkeditem   Open the \TeX book
  \checkeditem   Find the good page
  \item   Try to understand
\end{checklist}
\end{document}

The question is, here I use twocolumn option, but you see the checkitem box was put on the left, why? Can you help me, thanks.

See the screen shot image below:

check box on left page

EDIT:
This is the new code. I use the

\documentclass[a4paper,notitlepage]{article}
\usepackage{graphicx}
\usepackage[twocolumn]{geometry}
\usepackage{amssymb}
\usepackage{array}
\usepackage[export]{adjustbox}  % draw frame of the image
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm,headheight=1cm,headsep=1cm,footskip=1cm}

\usepackage{wasysym}

\setlength{\columnseprule}{0.4pt}
\setlength{\columnsep}{0.5in}

\newcommand\numitem[1]{\item #1 \hfill $\Box$}%
\newcommand\nonnumitem[1]{\item[--] #1 \hfill $\Box$}%


\begin{document}

\begin{enumerate}
  \numitem{Open the \TeX book Open the \TeX book Open the abc}
  \numitem{Find the good page}
  \nonnumitem{Try to understand}
\end{enumerate}

\newpage

\begin{enumerate}
  \numitem{Open the \TeX book Open the \TeX book Open the abcdefg}
  \numitem{Find the good page}
  \nonnumitem{Try to understand}
\end{enumerate}

\end{document} 

I found a bug that sometimes, the box was not put in the right side of the column, see the screen shot below:
box shown on the left

So, any idea to fix this? Thanks.

EDIT2
I found some code snippet which can solve this issue(force the box go to the right side), just change the code to:

\newcommand\numitem[1]{\item #1 \unskip\linebreak[0]\enspace\hbox{}\nobreak\hfill$\Box$}%
\newcommand\nonnumitem[1]{\item[--] #1 \unskip\linebreak[0]\enspace\hbox{}\nobreak\hfill$\Box$}%

Then, I can fix this bug, but can any till me what does the code means? Thanks.

Best Answer

The solution you're referring to doesn't work in two column mode, because the margin used to print the \marginpar is the left one when you are in the left column and the right one when you are in the right column.

This is a simple solution that doesn't use the margins to print the checkboxes, but it's far from perfect.

I've defined two new commands

\newcommand\noncheckeditem[1]{\item[--] #1 \hfill $\Box$}%
\newcommand\checkeditem[1]{\item[--] #1 \hfill $\CheckedBox$}%

to be used respectively when you want a non-checked and a checked item.

You can use them inside a normal description environment as follows:

\documentclass[a4paper,notitlepage]{article}
\usepackage{graphicx}
\usepackage[twocolumn]{geometry}
\usepackage{amssymb}
\usepackage{array}
\usepackage[export]{adjustbox}  % draw frame of the image
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm,headheight=1cm,headsep=1cm,footskip=1cm}

\usepackage{wasysym}

\setlength{\columnseprule}{0.4pt}
\setlength{\columnsep}{0.5in}

\newcommand\noncheckeditem[1]{\item[--] #1 \hfill $\Box$}%
\newcommand\checkeditem[1]{\item[--] #1 \hfill $\CheckedBox$}%

\begin{document}

\begin{description}
  \checkeditem{Open the \TeX book}
  \checkeditem{Find the good page}
  \noncheckeditem{Try to understand}
\end{description}

\newpage

\begin{description}
  \checkeditem{Open the \TeX book}
  \checkeditem{Find the good page}
  \noncheckeditem{Try to understand}
\end{description}

\end{document} 

Result:

enter image description here

Note that I've printed one on the left and one on the right column just to see how they look. For this purpose, I've also added the lines

\setlength{\columnseprule}{0.4pt}
\setlength{\columnsep}{0.5in}

Also note that the left and the right margin of your geometry are too small and you get warnings. You should put something like 3.5cm both for lmargin and rmargin.

Related Question