1

I created a new command to format a title and some paragraphs into a table style layout (I'm calling it a boombox).

The boombox command is:

\belowcaptionskip=-10pt
\setlength\arrayrulewidth{1pt}
\renewcommand\arraystretch{1.5}
\newcolumntype{I}{!{\vrule width 3pt}}
\newcommand\boombox[2]{
\begin{table}[H]
    \begin{tabular}{|Ip{5.67in}I|}
        \hhline{|t:=:t|}
        {#1} \\ \hhline{|:=:|}
        {#2} \\ \hhline{|b:=:b|}
    \end{tabular}
\end{table}}

I then call it out in the document:

\boombox{This is the title of the table}
        {This houses the 4 paragraphs I'm writing with \\ in between each one}

I am getting the two errors stated in the title of this post and I'm not sure why. Is it something to do with the paragraphs spanning multiple lines in the code?

Any help would be greatly appreciated!

  • Welcome! What's the purpose of the table environment? I see none. – egreg Dec 13 '16 at 23:48
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Dai Bowen Dec 13 '16 at 23:52
  • Without the table environment, the tabular environment was 'tabbed' over from the left margin and I need it to be centered. I wasn't sure how to fix this, but by putting into a table environment it I was able to modify the 5.67in value until it spanned the textwidth. I tried \centering but that didn't seem to help. If you have a better way of centering the tabular environment, that would be great! – cwebber Dec 13 '16 at 23:55
1

You need no table environment.

The error is in bracing #1 and #2:

\documentclass{article}
\usepackage{array,hhline}

\newcolumntype{I}{!{\vrule width 3pt}}
\renewcommand\arraystretch{1.5}

\newcommand\boombox[2]{%
  \par\noindent
  \begin{tabular}{|Ip{5.67in}I|}
  \hhline{|t:=:t|}
  #1 \tabularnewline \hhline{|:=:|}
  #2 \tabularnewline \hhline{|b:=:b|}
  \end{tabular}%
}

\begin{document}

\boombox{This is the title of the table}
        {This houses the 4 paragraphs I'm writing with \\ in between each one}

\end{document}

enter image description here

| improve this answer | |
  • That is exactly what I was looking for. Thank you! – cwebber Dec 13 '16 at 23:58

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.