[Tex/LaTex] Formatting answer boxes

formattingtikz-pgf

I am still very new to LaTeX and was drawn to its chemistry packages. Since this is my first semester using LaTeX for reports, however this class requires pre-lab reports to be submitted as well. Anyway, long story short this lab will require a LOT of data and would like to organise it better in my copy of the pre-lab report. Rather than keeping it in my notebook hastily written. But, it is very messy and have no idea how to format it. I can I think \hrule it to various measurements but there must be an easier way to pad everything right to the furthest question preceding the colon so everything is aligned properly.

Maybe there is a nicer way of doing the boxes as well as I am eager to learn this much as I can for my future scientific career.

Below is the area in question:

\section*{Data}
Boiling point at first drop: \answerbox \\
Boiling point at last drop: \answerbox \\
Tared flask weight with decanted solution (1.0 mg): \answerbox \\
Mass of essential oil after evaporation: \answerbox \\
Percent of essential oil based on mass of caraway oil: \answerbox \\
Mass of 2,4-DNP (\ce{C16H18O4N4}): \answerbox \\
Melting point of 2,4-DNP: \answerbox \\
Amount of carvone originally extracted: \answerbox \\
Amount of limonene in the oil: \answerbox \\
Percent of limonene: \answerbox \\
Percent of carvone: \answerbox \\
\tikz \draw[fill=yellow!3] (0,0) rectangle (\linewidth, -2in) node[pos=.14]   {Notes (Calculations/Odours):};

My preamble is here:

% Preamble
% -------------------------------------------------------------------------------
\documentclass{article}

\usepackage[letterpaper, portrait, margin=2cm]{geometry}
\usepackage[english]{babel}
\usepackage[protrusion=true,expansion=true]{microtype}  
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage[utf8]{inputenc}
\pagenumbering{roman}
\usepackage{graphicx}
\usepackage[svgnames,table,xcdraw,dvipsnames]{xcolor} 
\usepackage[version=3]{mhchem}
\usepackage{chemfig}
\usepackage{gensymb}

% ------------------------------------------------------------------------------
% Definitions (do not change this)
% ------------------------------------------------------------------------------
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}   % Horizontal rule

\makeatletter                           % Title
\def\printtitle{%                       
    {\centering \@title\par}}
\makeatother                                    

\makeatletter                           % Author
\def\printauthor{%                  
    {\centering \large \@author}}               
\makeatother                            

\newcommand\answerbox{%%
         \fbox{\rule{2.5cm}{0pt}\rule[-0.2ex]{0pt}{2ex}}}

This is what I have now/like to do

Best Answer

A pretty 'hack' ;-)

I put the descriptions into a comma separated list which is displayed by \MakeTable[options for answerbox]{width of description column}{width of answerbox}[Heading of notes box]<height of notes box>

More features could be added, but require time ;-)

\documentclass{article}

\usepackage[letterpaper, portrait, margin=2cm]{geometry}
\usepackage[english]{babel}
\usepackage[protrusion=true,expansion=true]{microtype}  
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage[utf8]{inputenc}
\pagenumbering{roman}
\usepackage{graphicx}
\usepackage[svgnames,table,xcdraw,dvipsnames]{xcolor} 
\usepackage[version=3]{mhchem}
\usepackage{chemfig}
\usepackage{gensymb}

\usepackage[most]{tcolorbox}

% ------------------------------------------------------------------------------
% Definitions (do not change this)
% ------------------------------------------------------------------------------
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}   % Horizontal rule

\makeatletter                           % Title
\def\printtitle{%                       
    {\centering \@title\par}}
\makeatother                                    

\makeatletter                           % Author
\def\printauthor{%                  
    {\centering \large \@author}}               
\makeatother                            


\newcommand{\answerbox}[1][]{%
\begin{tcolorbox}[nobeforeafter,width=2.5cm,enhanced jigsaw,colback=white,sharp corners,#1]
\end{tcolorbox}
}

\usepackage{array}

\usepackage{xparse}

\newtcolorbox{notesbox}[2][]{nobeforeafter,boxrule=0pt,colback=white,enhanced jigsaw,sharp corners,width=\linewidth,height=#2,#1}


\ExplSyntaxOn
\clist_new:N \g_jon_topics_clist

\NewDocumentCommand{\FillTopicsList}{m}{%
  \clist_set:Nn \g_jon_topics_clist {#1}
}

\NewDocumentCommand{\DisplayTopicsList}{O{}}{%
  \clist_map_inline:Nn \g_jon_topics_clist { ##1: & \answerbox[#1] \tabularnewline}
}

\ExplSyntaxOff

\NewDocumentCommand{\MakeTable}{O{}mmO{Notes(Calculations/Odours}D<>{0.4\textheight}}{%
  \begin{tabular}{m{#2}m{#3}}
    \tabularnewline
    \DisplayTopicsList[#1]
    \tabularnewline
    \hline
    \multicolumn{2}{|l|}{%
      #4
    }\tabularnewline
    \multicolumn{2}{|@{}l@{}|}{%
      \begin{notesbox}[#1]{#5}
      \end{notesbox}
    }\tabularnewline
    \hline
  \end{tabular}
}


\begin{document}
\section*{Data}
\FillTopicsList{Boiling point at first drop,Boiling point at last drop,
  Tared flask weight with decanted solution (1.0 mg),
  Mass of essential oil after evaporation,
  Percent of essential oil based on mass of caraway oil
  Mass of 2,4-DNP (\ce{C16H18O4N4}), 
  Melting point of 2,4-DNP, 
  Amount of carvone originally extracted, 
  Amount of limonene in the oil, 
  Percent of limonene,
  Percent of carvone,
}

\MakeTable{6cm}{2.5cm}<0.3\textheight>

\MakeTable[colback={yellow!40!white}]{6cm}{2.5cm}<0.3\textheight>


\end{document}

enter image description here

Related Question