1

I'm trying to make a page heading using

\documentclass[12pt]{article}

\usepackage{sidecap,wasysym,array,caption,graphicx}
\usepackage[a4paper,margin=1cm,footskip=.5cm]{geometry}
\pagenumbering{gobble}

\newcommand\textbox[1]{%
  \parbox[t]{.333\textwidth}{#1}%
}

\begin{document}

\noindent\textbox{Date: \begin{tabular}[t]{|l|l|l|l|l|l|}
                        \hline
                        & & & & & \\
                        \hline
                        \end{tabular}}
                        \hfill\textbox{\hfil \textsc{\LARGE Content}\hfil}\textbox{\hfill\LARGE\smiley{}}

\end{document}

enter image description here

in which I'm trying to make a box using a table, to fill in the date. But the box and the text "Date:" don't seem to align. I already tried doing Align text and image on the same line? but I'm not sure if it is the right way to go about it. How can I align the "Date:" and the table in the same line?

3
  • 2
    Try \begin{tabular}[b]{...} or merge 'Date' into table, i.e. `\begin{tabular}{l|*{6}{l|}}{\cline{2-7} Date: & & & & & \\ ... \end{tabular}
    – user31729
    Sep 4, 2015 at 7:40
  • @ChristianHupfer, or simple \begin{tabular}{...}, which gives the same result as Heiko Oberdiek answer.
    – Zarko
    Sep 4, 2015 at 8:16
  • Yeah, removing the [t] alignment from tabular gives the same result as Heiko Oberdiek's answer. Thanks @ChristianHupfer and @Zarko :) Sep 4, 2015 at 8:37

1 Answer 1

2

The top element of the table is not the first row, but the line above it.

Usually a tabular row has a strut with .7\baselineskip as height and .3\baselineskip below (multiplied with \arraystretch). Since digits usually do not have descenders, the following example aligns the table at the bottom line, but moves it down 2/3 of the descender (.2\baselineskip) as compromise:

\documentclass[12pt]{article}

\usepackage{sidecap,wasysym,array,caption,graphicx}
\usepackage[a4paper,margin=1cm,footskip=.5cm]{geometry}
\pagenumbering{gobble}

\newcommand\textbox[1]{%
  \parbox[t]{.333\textwidth}{#1}%
}

\begin{document}

\noindent
\textbox{%
  Date: %
  \raisebox{-.2\baselineskip}{%
    \begin{tabular}[b]{|l|l|l|l|l|l|}
      \hline
      & & & & & \\
      \hline
    \end{tabular}%
  }%
}%
\hfill
\textbox{\hfil \textsc{\LARGE Content}\hfil}%
\textbox{\hfill\LARGE\smiley{}}

\end{document}

Result

4
  • Didn't know about that regarding the top element of a table, thanks! Sep 4, 2015 at 7:47
  • Can the whole pdf be posted as an image like you did in my last question, or do we have to take a screenshot and upload it as an image? Sep 4, 2015 at 7:51
  • @VinayakMehta Some time ago, it was possible to upload PDF, which was converted automatically to PNG, but the current upload form only supports "jpeg, png, tiff, gif or bmp". Usually, I remove the page number at TeX level, run TeX to get the PDF, remove the margins with pdfcrop and convert it to PNG (with transparency to remove the white background) via ghostscript. Most of it can be automated by a script. Sep 4, 2015 at 7:56
  • Learning something new everyday on TeX.SX! :D Sep 4, 2015 at 8:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .