2

How make top left alignment (yellow rectangle) and middle left alignment (red rectangle) of text inside cell?

I've tried a lot different options, I think alignment should be specified directly in cell; not in begining of table in my case.

\topleftalignment{Klient:}

enter image description here

my code:

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{array}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{makecell}
\usepackage[export]{adjustbox}
\usepackage{graphbox}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{graphicx}

\usepackage{geometry}
\geometry{paper=a4paper}
\geometry{bindingoffset=1.5cm,hmargin={1.5cm,1.5cm},vmargin={1cm,1cm},
includehead=false,
includefoot=true,footskip=10cm}

\pagestyle{fancy}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}

\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyfoot[CE,CO,LE,LO,RE,RO]{} %% clear out all footers
\fancyhf{}                      %% clear default for head and foot
\fancyfoot[C]{%
    \begin{tikzpicture}[remember picture,overlay]
    \node[anchor=south west,inner sep=0pt] at ($(current page.south west)+(2.5cm,1cm)$) {
        \begin{tabular}{@{}p{3cm}@{}@{}p{2.95cm}@{}|@{}p{2.3cm}@{}|@{}p{2.3cm}@{}@{}p{2.3cm}@{}|@{}p{2.3cm}@{}@{}p{1.5cm}@{}@{}p{0.8cm}@{}}
        \cline{3-8}     
        &
        &
        & \multicolumn{1}{c|}{}
        &
        & \multicolumn{1}{c|}{}
        & \multicolumn{2}{c }{}
        \bigstrut\\ \cline{3-8}         
        &
        &
        & \multicolumn{1}{c|}{}
        &
        & \multicolumn{1}{c|}{}
        & \multicolumn{2}{c }{}
        \bigstrut\\ \cline{3-8}         
        &
        &
        & \multicolumn{1}{c|}{}
        &
        & \multicolumn{1}{c|}{}
        & \multicolumn{2}{c }{}
        \bigstrut\\ \cline{3-8}         
        &
        & \centering\textbf{\scriptsize A}
        & \multicolumn{1}{c|}{\textbf{\scriptsize 1}}
        & \centering\textbf{\scriptsize 1}
        & \multicolumn{1}{c|}{\textbf{\scriptsize 1}}
        & \multicolumn{2}{c }{\textbf{\scriptsize 1}}
        \bigstrut\\ \cline{3-8}         
        &
        & \multicolumn{1}{c|}{\scriptsize Rev.:}
        & \multicolumn{1}{c|}{\scriptsize Datum:}
        & \multicolumn{1}{c|}{\scriptsize Gezeichnet:}
        & \multicolumn{1}{c|}{\scriptsize Überprüft:}
        & \multicolumn{2}{c }{\scriptsize Genehmigt:}
        \bigstrut\\ \hline
        \scriptsize Klient:
        & \multicolumn{3}{c}{\includegraphics[valign=c,scale=0.2]{example-image-a}}
        & \multicolumn{3}{l}{\footnotesize Dummy text}
        \bigstrut\\ \hline
        \scriptsize Auftragnehmer:
        & \multicolumn{3}{c}{\includegraphics[valign=c,scale=0.2]{example-image-a}}
        & \multicolumn{3}{l}{\footnotesize Dummy text}
        \bigstrut\\ \hline
        \multicolumn{2}{@{}l|}{\scriptsize Projekt:}
        & \scriptsize Vertrag Nr.:
        & \multicolumn{3}{@{}l|}{\scriptsize Dokument Nr.:}
        & \scriptsize Seite:
        & \textbf{\footnotesize \thepage}
        \bigstrut\\ \cline{7-8} 
        \multicolumn{2}{c|}{\textbf{\makecell{\footnotesize 1}}}
        &
        & \multicolumn{3}{c|}{\textbf{\footnotesize 1}} 
        & \makecell[l]{\scriptsize Gesamte\\\scriptsize Seite:}
        & \textbf{\footnotesize \pageref*{LastPage}}
        \bigstrut\\ \hline
        \multicolumn{2}{@{}l|}{\scriptsize Titel:}
        & \scriptsize Rahmen:
        & \multicolumn{3}{@{}l|}{\scriptsize Rev.:}
        & \scriptsize Format:
        & \textbf{\footnotesize A4}
        \bigstrut\\ \cline{7-8} 
        \multicolumn{2}{c|}{\textbf{\footnotesize 1}}
        & \centering\textbf{\footnotesize 1:1}
        & \multicolumn{3}{c|}{\textbf{\footnotesize A}}
        & \scriptsize Sprache:
        & \textbf{\footnotesize DE}
        \bigstrut\\ \hline
        \end{tabular}%
    };
    \end{tikzpicture}
}

\begin{document}
Dummy text
\end{document}
3
  • welcome to tex.se! please, reduce your document example only to table. now is to easy going to lost in your code. for vertical centering of text in rows with images you need to move image baseline to the middle of figure. this can be done on many ways. one of it is use adjustbox and his macro valign=c. for an example see tex.stackexchange.com/questions/270582.
    – Zarko
    Jul 6 '18 at 9:35
  • you miss understood me. we need complete document which contain only table. all stuff regarding headers, footers etc are superfluous. in preamble should be only packages needed to compile your table. do you look given link? it could solve problem, i thing.
    – Zarko
    Jul 6 '18 at 9:59
  • Hi @Zarko, I have reduced document example with only table in it. I have tried with \multicolumn{3}{c}{\includegraphics[valign=c,scale=0.2]{example-image-a}} as you told me. This caused whole row to be centered, I like 2nd and 3rd column getting centered, but can I make top left alignment of 1st colum? Thank you in advance! I will put updated output of code in post.
    – Beginner
    Jul 6 '18 at 10:00
2

You can easily obtain cells in the same row centred w.r.t. the image, with the option align=c that package graphbox adds to \includegraphics.

As to having one cell in the row top-aligned, you can do that with a hack: using \multirow{-n}, where n is a number of lines found by trial and error.

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{array}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{background}
\usepackage{lipsum}
\usepackage{makecell}
\usepackage[export]{adjustbox}
\usepackage{graphbox}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{graphicx}

\usepackage{geometry}
\geometry{paper=a4paper}
\geometry{bindingoffset=1.5cm,hmargin={1.5cm,1.5cm},vmargin={1cm,1cm}}
\geometry{includehead=true,headheight=3cm,headsep=1cm}
\geometry{includefoot=false}

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt} %%delete default header line

\usetikzlibrary{calc}
\usetikzlibrary{positioning}

\SetBgOpacity{100.0}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgContents{
\begin{tikzpicture}[overlay,remember picture]
\draw [line width=1pt,rounded corners=0pt]
($ (current page.north west) + (2.5cm,-1cm) $)
rectangle
($ (current page.south east) + (-1cm,1cm) $);

\draw [line width=1.5pt]
($ (current page.north west) + (2.5cm,-14.85cm) $) -- ($ (current page.north west) + (1cm,-14.85cm) $);

\node[anchor=north] at ($(current page.north west)+(1.5cm,-1cm)$) {\rotatebox{90}{\makecell[r]{\scriptsize\selectfont Reproduction or any use not conformity with the intended\\
            \scriptsize\selectfont application is not permissible.}}};
\node[anchor=south] at ($(current page.south west)+(1.5cm,1cm)$) {\rotatebox{90}{\makecell[l]{\scriptsize\selectfont Nachdruck oder Verwendung, die nicht der beabsichtigten\\
            \scriptsize\selectfont Anwendung entspricht, ist nicht zulässig.}}};

\end{tikzpicture}
}

\fancypagestyle{firstpage}{%
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyfoot[CE,CO,LE,LO,RE,RO]{} %% clear out all footers
\fancyhf{} %% clear default for head and foot
\fancyfoot[C]{%
    \begin{tikzpicture}[remember picture,overlay]
    \node[anchor=south west,inner sep=0pt] at ($(current page.south west)+(2.5cm,1cm)$) {
\setcellgapes{3pt}\makegapedcells
        \begin{tabular}%
{@{}p{3cm}@{}@{}p{2.95cm}@{}|@{}p{2.3cm}@{}|@{}p{2.3cm}@{}@{}p{2.3cm}@{}|@{}p{2.3cm}@{}@{}p{1.5cm}@{}@{}p{0.8cm}@{}}
        \cline{3-8}
        & & & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c }{}
        \bigstrut\\ \cline{3-8}
        & & & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c }{}
        \bigstrut\\ \cline{3-8}
        & & & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c }{}
        \bigstrut\\ \cline{3-8}
        & & \centering\textbf{\scriptsize A} & \multicolumn{1}{c|}{\textbf{\scriptsize 1}} & \centering\textbf{\scriptsize 1}
        & \multicolumn{1}{c|}{\textbf{\scriptsize 1}} & \multicolumn{2}{c }{\textbf{\scriptsize 1}}
        \bigstrut\\ \cline{3-8}
        &
        & \multicolumn{1}{c|}{\scriptsize Rev.:} & \multicolumn{1}{c|}{\scriptsize Datum:} & \multicolumn{1}{c|}{\scriptsize Gezeichnet:} & \multicolumn{1}{c|}{\scriptsize Überprüft:} & \multicolumn{2}{c }{\scriptsize Genehmigt:}
        \bigstrut\\ \hline
       \multirow{-4}{=}{\scriptsize Klient:} & \multicolumn{3}{c}{\includegraphics[scale=0.2, align = c]{example-image-a}} & \multicolumn{3}{l}{\footnotesize Dummy text}
        \bigstrut\\ \hline
        \multirow{-4}{=}{\scriptsize Auftragnehmer:} & \multicolumn{3}{c}{\includegraphics[scale=0.2, align = c]{example-image-a}} & \multicolumn{3}{l}{\footnotesize Dummy text}
        \bigstrut\\ \hline
        \multicolumn{2}{@{}l|}{\scriptsize Projekt:} & \scriptsize Vertrag Nr.: & \multicolumn{3}{@{}l|}{\scriptsize Dokument Nr.:} & \scriptsize Seite: & \textbf{\footnotesize \thepage}
        \bigstrut\\ \cline{7-8}
        \multicolumn{2}{c|}{\textbf{\makecell{\footnotesize 1}}} & & \multicolumn{3}{c|}{\textbf{\footnotesize 1}}
        & \makecell[l]{\scriptsize Gesamte\\\scriptsize Seite:} & \textbf{\footnotesize \pageref*{LastPage}}
        \bigstrut\\ \hline
        \multicolumn{2}{@{}l|}{\scriptsize Titel:} & \scriptsize Rahmen: & \multicolumn{3}{@{}l|}{\scriptsize Rev.:} & \scriptsize Format: & \textbf{\footnotesize A4}
        \bigstrut\\ \cline{7-8}
        \multicolumn{2}{c|}{\textbf{\footnotesize 1}} & \centering\textbf{\footnotesize 1:1} & \multicolumn{3}{c|}{\textbf{\footnotesize A}}
        & \scriptsize Sprache: & \textbf{\footnotesize DE}
        \bigstrut\\ \hline
        \end{tabular}%
    };
    \end{tikzpicture}
}
}

\begin{document}

\thispagestyle{firstpage}
\newgeometry{bindingoffset=1.5cm,hmargin={1.5cm,1.5cm},vmargin={1cm,1cm},
    includehead=false,
    includefoot=true,footskip=10cm
}
%\vspace*{6cm}
%\begin{center}
% \Huge Some random text\\
% \large Some random text\\~\\
% \Huge Some random text\\
% \large Some random text
%\end{center}
\vspace*{\fill}

\end{document} 

enter image description here

2
  • Hi @Bernard, first of all thank you for your help! You have put \setcellgapes{3pt}\makegapedcells into my code, this is option for additional gape in whole table. I would like to add gapes only in two rows where I have put my figures. Is that possible?
    – Beginner
    Jul 6 '18 at 11:29
  • 1
    @DominikGečević: Yes. You can use \Gape[3pt]{\includegraphics{...}} instead. This is explained in § 2 of the doc of makecell (p. 7).
    – Bernard
    Jul 6 '18 at 16:09

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.