0

I'm trying to create a title for my page like this: enter image description here I used this:

\documentclass[10pt,a4paper]{article}

\usepackage[top=1in, bottom=1.25in, left=1.25in, right=1.25in]{geometry} 
\geometry{a4paper} 
\usepackage{booktabs,tabularx,multirow}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage[table]{xcolor}
\definecolor{light-gray}{gray}{0.95}
\usepackage{graphicx}

\begin{document}
\begin{table}[h!]
    \centering
\begin{tabularx}{\textwidth}{ YYY }
  \toprule
  \toprule
  \rowcolor{light-gray}

  somthing & &  something  \\
  \rowcolor{light-gray}
 something & \includegraphics[width=0.5\linewidth]{Figures/KNTU.pdf}&  something   \\
    \rowcolor{light-gray}
 something && something    \\
  \bottomrule
  \bottomrule
\end{tabularx}
\end{table}



\end{document}

and i got this:

enter image description here

I can't figure out whats wrong!!

2

That is because \includegraphics lays the bottom of image on the baseline. A \raisebox{-0.5\height} does the trick. It's harder to add vertical spacing between top and bottom rules, because of the coloured rows. The simplest is to add a horizontal rule with the desired height,of width \textwidth, and with the same colour as the rows background. In the following code I added rules 10pt high under the top rules and above the bottomrules.

I added some improvements to the rest of your code: using booktabs with colors in cells or rows results in small white strips at the top and the bottom of cells, a consequence of the \aboverulesep and \belowrulesep vertical spaces added around rules. I managed to compensate for this difficulty.

\documentclass[10pt,a4paper]{article}

\usepackage[top=1in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
\geometry{a4paper}
\usepackage{booktabs,tabularx,multirow, boldline}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage[table, svgnames]{xcolor}
\colorlet{light-gray}{Lavender!60!}
\usepackage{graphicx}

\begin{document}

\begin{table}[h!]
    \centering
\begin{tabularx}{\textwidth}{YYY }
  \toprule
\noalign{\vspace*{-1pt}}
  \hlineB{2}
\noalign{\textcolor{light-gray}{\rule{\textwidth}{10pt}}}
\rowcolor{light-gray} something & & something \\
  \rowcolor{light-gray}
 something & \raisebox{-0.5\height}{\includegraphics[width=0.5\linewidth]{euclid}}& something \\
    \rowcolor{light-gray}
 something && something \\
\noalign{\textcolor{light-gray}{\rule{\textwidth}{10pt}}}
\addlinespace[-\aboverulesep]
  \bottomrule
  \bottomrule
\end{tabularx}
\end{table}

\end{document} 

enter image description here

  • According to the question's title, the OP wants this on the top of the first page, so a table environment doesn't seem the best solution. – egreg Oct 6 '16 at 11:18
  • I didn't notice it. I'll remove the environment. Thanks! – Bernard Oct 6 '16 at 11:33
  • Thanks. How can I create a space between my text and top and bottom line?? – H.H Oct 6 '16 at 11:53
  • Do you mean between the text in the table, and the top and the bottom lines? I've added a way to do that. Please see my updated answer. – Bernard Oct 6 '16 at 17:22
1

The table is just right, the middle somethings are aligned to the bottom vertically. One way of solving this is using the array definition of m{1.75in}. Here's my MWE

\documentclass[10pt,a4paper]{article}

\usepackage[top=1in, bottom=1.25in, left=1.25in, right=1.25in]{geometry} 
\geometry{a4paper} 
\usepackage{booktabs,tabularx,multirow}
\newcolumntype{Y}{>{\centering\arraybackslash}m{1.75in}}
\usepackage[table]{xcolor}
\definecolor{light-gray}{gray}{0.95}
\usepackage{graphicx}

\begin{document}
    \begin{table}[h!]
        \centering
        \begin{tabularx}{\textwidth}{ YYY }
            \toprule
            \toprule
            \rowcolor{light-gray}

            somthing & &  something  \\
            \rowcolor{light-gray}
            something & \includegraphics[width=0.5\linewidth]{example-image}&  something   \\
            \rowcolor{light-gray}
            something && something    \\
            \bottomrule
            \bottomrule
        \end{tabularx}
    \end{table}



\end{document}

Of course any other vertical alignment to the center would work as a solution.

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.