Graphics, Figures & Tablestable formatting

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

table formatting

Post by mayankmi »

I am preparing a simple time sheet for my car driving course.
I just want the last colomn where i check tick or no tick to be in center.

Code: Select all

\documentclass[letterpaper,12pt]{article} 
\pagestyle{empty} % No footer 
\usepackage[hmargin=0.50in, vmargin=0.50in]{geometry} 
\usepackage{multicol} % Rows spanning multiple columns 
\usepackage{wasysym} % Square images 
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[normalem]{ulem} % Colorful links 
\usepackage{hyperref, xcolor} % Colorful links 
\usepackage{graphicx} % Figures 
\usepackage{pifont}
\usepackage{tabularx} % newcolumntype 
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%

\usepackage{amssymb,tikz,pdftexcmds,xparse}

\tikzset{box/.style={
    minimum size=0.225cm,
    inner sep=0pt,
    draw,
  },  
  insert mark/.style={
    append after command={%
         node[inner sep=0pt,#1]
           at (\tikzlastnode.center){$\checkmark$}
     }     
  },
  insert bad mark/.style={
    append after command={%
         [shorten <=\pgflinewidth,shorten >=\pgflinewidth]
         (\tikzlastnode.north west)edge[#1](\tikzlastnode.south east)
         (\tikzlastnode.south west)edge[#1](\tikzlastnode.north east)
     }     
  },
}

\makeatletter
\NewDocumentCommand{\tikzcheckmark}{O{} m}{%
  \ifnum\pdf@strcmp{#2}{mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,insert mark={#1},#1]{};%
  \fi%
  \ifnum\pdf@strcmp{#2}{bad mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,insert bad mark={#1},#1]{};%
  \fi%
  \ifnum\pdf@strcmp{#2}{no mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,#1]{};%
  \fi%
}
\makeatother


\begin{document} 
\begin{center}
CAR DRIVING TIME SHEET
\end{center}
Employee Name: \underline{XXXXXXMotor Training School}  
\newcommand{\DAY}[3]{DAY \##1 \hspace{0.2in} #2 ~ #3\\} 
 \begin{multicols}{2} \noindent 
 \DAY{1~}{04/10/13 -- FRIDAY}{\tikzcheckmark[scale=1.25,red]{mark}}
 \DAY{2~}{05/10/13 -- SATURDAY}{$\text{\rlap{$\checkmark$}}\square$}
 \DAY{3~}{06/10/13 -- SUNDAY}{$\boxtimes$}
 \DAY{4~}{07/10/13 -- MONDAY}{$\text{\rlap{$\checkmark$}}\square$}
 \DAY{5~}{08/10/13 -- TUESDAY}{$\text{\rlap{$\checkmark$}}\square$}
 \DAY{6~}{09/10/13 -- WEDNESDAY}{$\text{\rlap{$\checkmark$}}\square$}
 \DAY{7~}{10/10/13 -- THURSDAY}{$\boxtimes$}
 \DAY{8~}{11/10/13 -- FRIDAY}{$\boxtimes$} 
 \vfill \columnbreak \noindent 
 \DAY{9}{12/10/13 -- SATURDAY}{$\boxtimes$} 
 \DAY{10}{13/10/13 -- SUNDAY}{$\boxtimes$} 
  \end{multicols} 

 
   \end{document} 

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

Re: table formatting

Post by mayankmi »

I would like the last column to be centered..please see screenshot of output which is coming..
Attachments
Screen Shot 2013-10-12 at 8.36.48 PM.png
Screen Shot 2013-10-12 at 8.36.48 PM.png (66.02 KiB) Viewed 6443 times
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

table formatting

Post by mas »

I presume that the check marks will be done by hand daily on the printed sheet. In that case, having tick marks in the boxes might not be desirable. If you are generating this from a database of records, then it is a different matter.

Regarding your problem, why not use {tabular} rather than {multicols} to achieve the desired result? The output as posted does not look that good. By using \tabular or one of its variants, you can achieve a much better consistency in the output.

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

table formatting

Post by mas »

When I tried compiling your example, I am getting the following error:

Code: Select all

...
(/home/software/texlive/2013/texmf-dist/tex/latex/amsmath/amsopn.sty)

! LaTeX Error: Command \iint already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.505 ...d{\iint}{\DOTSI\protect\MultiIntegral{2}}
                                                  
? 

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

table formatting

Post by cgnieder »

Why don't you use a table?

Code: Select all

\documentclass[letterpaper,12pt]{article} 
\pagestyle{empty} % No footer 
\usepackage[hmargin=0.50in, vmargin=0.50in]{geometry} 
\usepackage{multicol} % Rows spanning multiple columns 
\usepackage{wasysym} % Square images 
\usepackage{amssymb}
%% those two are defined already; let's ``undefine'' them to avoid errors:
\let\iint\relax
\let\iiint\relax
\usepackage{amsmath}
\usepackage[normalem]{ulem} % Colorful links 
\usepackage{hyperref, xcolor} % Colorful links 
\usepackage{graphicx} % Figures 
\usepackage{pifont}
\usepackage{tabularx} % newcolumntype 
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%

\usepackage{amssymb,tikz,pdftexcmds,xparse}

\tikzset{box/.style={
    minimum size=0.225cm,
    inner sep=0pt,
    draw,
  },  
  insert mark/.style={
    append after command={%
         node[inner sep=0pt,#1]
           at (\tikzlastnode.center){$\checkmark$}
     }     
  },
  insert bad mark/.style={
    append after command={%
         [shorten <=\pgflinewidth,shorten >=\pgflinewidth]
         (\tikzlastnode.north west)edge[#1](\tikzlastnode.south east)
         (\tikzlastnode.south west)edge[#1](\tikzlastnode.north east)
     }     
  },
}

\makeatletter
\NewDocumentCommand{\tikzcheckmark}{O{} m}{%
  \ifnum\pdf@strcmp{#2}{mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,insert mark={#1},#1]{};%
  \fi%
  \ifnum\pdf@strcmp{#2}{bad mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,insert bad mark={#1},#1]{};%
  \fi%
  \ifnum\pdf@strcmp{#2}{no mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,#1]{};%
  \fi%
}
\makeatother

\usepackage{tabularx}

\begin{document} 
\begin{center}
CAR DRIVING TIME SHEET
\end{center}
Employee Name: \underline{XXXXXXMotor Training School}  
\newcommand{\DAY}[3]{DAY \##1 & #2 & #3}

\noindent
\begin{tabularx}{\textwidth}{llXllX}
 \DAY{1}{04/10/13 -- FRIDAY}{\tikzcheckmark[scale=1.25,red]{mark}} &
   \DAY{9}{12/10/13 -- SATURDAY}{$\boxtimes$} \\
 \DAY{2}{05/10/13 -- SATURDAY}{$\text{\rlap{$\checkmark$}}\square$} &
  \DAY{10}{13/10/13 -- SUNDAY}{$\boxtimes$} \\
 \DAY{3}{06/10/13 -- SUNDAY}{$\boxtimes$} \\
 \DAY{4}{07/10/13 -- MONDAY}{$\text{\rlap{$\checkmark$}}\square$} \\
 \DAY{5}{08/10/13 -- TUESDAY}{$\text{\rlap{$\checkmark$}}\square$} \\
 \DAY{6}{09/10/13 -- WEDNESDAY}{$\text{\rlap{$\checkmark$}}\square$} \\
 \DAY{7}{10/10/13 -- THURSDAY}{$\boxtimes$} \\
 \DAY{8}{11/10/13 -- FRIDAY}{$\boxtimes$} 
\end{tabularx}

\end{document}
Regards
site moderator & package author
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

Re: table formatting

Post by mayankmi »

you are right.. no need to make life complex if things can be much simple.. thank you very much :idea:
Post Reply