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.

How can I create a command for a 2 tables with a label on top and a command for the options below? example of what i am saying is:

enter image description here

share|improve this question
    
Can you post the code which you have tried so far? –  Harish Kumar Dec 9 '12 at 15:11
    
I am actually trying to modify my code and it turns out like this :P \documentclass{article} \begin{document} \begin{tabular}{|l|c|p{1.7cm}|} \hline Good & Bad \\hline \ \ \hline \end{tabular} \end{document} –  Kayla Dec 9 '12 at 15:26
    
@kayla See my updated answer. :) –  azetina Dec 9 '12 at 21:00
add comment

1 Answer 1

The following is a simple way of achieving what you want. I will add further clarification if you want:

enter image description here

\documentclass{article}
\usepackage[margin=1in]{geometry}  % http://ctan.org/pkg/geometry
\usepackage{lipsum,tabularx,array} % http://ctan.org/pkg/{lipsum,tabularx}
\usepackage{multicol,enumitem}     % enables multicolumns and custom enumeration

\setlength{\parindent}{0pt}
\begin{document}
%
Write the following in its proper places.\\[2ex]
% This defines the new column type to have the words Good and Bad centered to fit what the OP wants. 
% Unfortunately, I couldn't figure out how to have it in a single table. Probably a using \multicolumn might work.
\newcolumntype{C}{>{\centering\arraybackslash}X} 
\begin{tabularx}{\linewidth}{CC}
Good & Bad
\end{tabularx}
%
\begin{tabularx}{\linewidth}{|X|X|}
\hline
  & \\[5cm] % Increase or decrease the table height
\hline
\end{tabularx}
% Declare the options here
\begin{multicols}{5}
\begin{itemize}[label=$-$]
\item Smoking
\item Drinking liquor
\item Exercise
\item Studying
\item Fighting
\item Vegetables
\item Crying
\item Sitting
\item Lying
\item Honest
\item Brave
\end{itemize}
\end{multicols}
\end{document}

Can you figure it out from here? That is, how to create the commands?


Am leaving the above as a reference for you to compare the definitions of the commands and the application of options to achieve the results:

\documentclass{article}
\usepackage[margin=1in]{geometry}    % http://ctan.org/pkg/geometry
\usepackage{lipsum,tabularx,array}   % http://ctan.org/pkg/{lipsum,tabularx}
\usepackage{multicol,enumitem,tikz}  % TiKZ offers the \foreach command used below.
\setlength{\parindent}{0pt}

\newcolumntype{C}{>{\centering\arraybackslash}X}%

% Defining the table with 3 options: 2 for table headers and one for the desired height
% for the table.
\newcommand{\tableclassification}[3]{%
\begin{tabularx}{\linewidth}{CC}
#1 & #2
\end{tabularx}
\begin{tabularx}{\linewidth}{|X|X|}
\hline
  & \\[#3] % Increase or decrease the table height
\hline
\end{tabularx}
}

% Offers a simple command to get the options for the table. The first option controls the
% controls the number of columns to be used and the last controls the data or options.
\newcommand{\tableoptions}[2]{%
\begin{multicols}{#1}
\begin{itemize}[label=$-$]
\foreach \tabopt in {#2}
{%
\item \tabopt%
}
\end{itemize}
\end{multicols}
}

\begin{document}
\tableclassification{Good}{Bad}{5cm}
\tableoptions{5}{Smoking, Drinking Liquor, Exercise, Studying, Fighting, Vegetables, Crying, Sitting, Lying, Honest, Brave}
\end{document}
share|improve this answer
add comment

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.