1

First time here so I apologize if I don't ask this correctly.

I currently have a tabular environment in my document which looks similar to: Tabbed List
using the following code

{\scriptsize\begin{tabular}{|p{.5in}|p{.5in}|p{.5in}|p{.5in}|p{.5in}|} \hline 
Alpha & Bravo & Charlie & Delta & Echo \\ \hline 
Foxtrot & Gulf & Hotel & India & Juliett \\ \hline 
Kilo & Lima & November & Oscar & Papa \\ \hline 
\end{tabular}}\\

Being tabular specifically is not important, nor are the lines around the items (in fact I'll probably remove them eventually...) But what I'd like is to be able to easily add or remove items from this list, for example to insert "Mike" in its proper location without having to manually adjust the placement of everything following while still having the list fit onto a sheet of paper. Breaking pages or preventing such is not important because this list lies in the middle of a form and will never be allowed to get that close to an edge.

The ultimate goal is to have an alphabetical list of items to be circled or highlighted as they apply... I know I'll need to work on vertical spacing as well and probably a centered list would look better, but I'm more concerned with getting the list to be easily edited first.

4

I think you are looking for something like

enter image description here

\documentclass{article}

\begin{document}

\newcommand\zz[1]{\makebox[.5in][l]{\scriptsize#1}\hfill\ignorespaces}

\begin{minipage}{2.5in}\raggedright
\zz{Alpha} \zz{Bravo} \zz{Charlie} \zz{Delta} \zz{Echo} 
\zz{Foxtrot} \zz{Gulf} \zz{Hotel} \zz{India} \zz{Juliett} 
\zz{Kilo} \zz{Lima}
\zz{Mike}
 \zz{November} \zz{Oscar} \zz{Papa} 
\end{minipage}


\end{document}
1

Here's another idea. David's is a lot simpler and if it works for you, great! This version is a bit more flexible depending on your needs. I put liberal comments to explain how it works. Better TeXies than I might be able to suggest improvements to my code, but here goes:

\documentclass{article}
\usepackage{array} % required for `>` in tabular preamble
\newcount\myfield  % keep track of how many fields across we are
\newcount\maxfield % maximum number of fields
\def\z{% use \z as a separator inside mylist instead of & or \\
  \ifnum \myfield < \maxfield% we haven't made it across the row yet
    \def\mydefer{&}% insert a standard column separator
  \else% we have made it across the row
    \def\mydefer{%
      \global\myfield 0\relax% reset field counter
      \\\hline% go to next row
    }%
  \fi%
  \mydefer% insert the appropriate column or row separator
}
\newenvironment{mylist}[2][l]% two arguments: #1 = column-spec (optional, default `l`); #2 = number of fields per row
{% opening of environment
  \myfield 0\relax% initialize at the "zeroeth" field
  \maxfield #2\relax% set max fields for this environment
  \scriptsize% choose font if desired
  \begin{tabular}{|*{#2}{>{\global\advance\myfield 1\relax}#1|}}% #2 copies of column #1, advance field count before each cell
  \hline% horizontal rule if desired
}{% closing of environment (much simpler if you decide to drop the rules)
  \ifnum\myfield=0\hline\else\\\cline{1-\myfield}\fi% draw a partial rule or full rule depending on number of fields in the last row
  \end{tabular}
}

\begin{document}
\begin{mylist}{5}
Alpha \z 
Bravo \z 
Charlie \z Delta \z Echo \z Foxtrot \z
Gulf \z Hotel \z
India \z Juliett \z Kilo \z Lima \z Mike \z November \z Oscar \z Papa
\end{mylist}

\begin{mylist}{3}
A \z Test \z for \z different \z parameters
\end{mylist}

\begin{mylist}[c]{2}
A \z Test \z for \z different \z parameters
\end{mylist}

\begin{mylist}[p{0.75in}]{2}
A \z Test \z for \z different \z parameters
\end{mylist}

\begin{mylist}[l]{7}
Alpha \z 
Bravo \z 
Charlie \z Delta \z Echo \z Foxtrot \z
Gulf \z Hotel \z
India \z Juliett \z Kilo \z Lima \z Mike \z November \z Oscar \z Papa
\end{mylist}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.