4

I am writing some project references and I would like to create the following layout:

enter image description here

Now I have been trying around and I got to the following layout:

enter image description here

For the moment I created a table to keep the columns, but I need a way to adjust the text on the left column more towards the left side, so the text does not just start right in the middle of the left column. How can I do that?

My code:

% !TeX program = lualatex
\documentclass[a4paper,12pt]{article}

%font encoding
\usepackage[onehalfspacing]{setspace}
\usepackage{fontspec}
\setmainfont{Arial}
\usepackage[document]{ragged2e}
\usepackage[textwidth=160mm, textheight=240mm]{geometry} 

%language
\usepackage[ngerman]{babel}
\usepackage{lipsum}

%table format
\usepackage{tabularx}
\usepackage{float}

%Styles
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usepackage{atbegshi}
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{lipsum}

\pagenumbering{gobble}

\definecolor{bluey}{RGB}{12,3,150}

\newcommand\Sitebar{%
    \begin{tikzpicture}[remember picture,overlay]
    \fill[lightgray]
    (current page.north west) -- ([xshift = 4cm]current page.north west) --
    ([xshift=7cm]current page.north west) --
    ([xshift=7cm]current page.south west) -- 
    ([xshift=0cm]current page.south west) -- cycle;
    \draw [gray, line width = 1.5pt] ([xshift=7cm]current page.north west) --
    ([xshift=7cm]current page.south west);
    \end{tikzpicture}%
}

%header format
\newcommand\HeaderTwo{%
    \begin{tikzpicture}[remember picture,overlay]
    \fill[bluey]
    (current page.north west) -- (current page.north east) --
    ([yshift=0.5cm]current page.north east|-current page text area.north east) --
    ([yshift=1.5cm]current page.north west|-current page text area.north west) -- cycle;
    \end{tikzpicture}%
}

% left separator
\newcommand\sepLeft{%
    \vspace{0.5cm}
    \begin{tikzpicture}[remember picture,overlay]
        \vspace{1cm}
        \draw [black, line width = 2pt] (-1.75,0.5) -- (3.8,0.5);
        \draw [bluey, line width = 2pt] (5.2,0.5) -- (17.5,0.5);
    \end{tikzpicture}%
}

\begin{document}
    \Sitebar
    \HeaderTwo
    \hspace{5cm} \textbf{\Huge \color{gray} Projektreferenzen}\\
    %separator
    \sepLeft
    \begin{table}[H]
        \begin{tabularx}{\linewidth}{ p{4cm} p{0.2cm} p{10cm}}
            Very Very long text to see how big this tabular actually is && \lipsum[1]
        \end{tabularx}
    \end{table}

\end{document}
  • 2
    You've told tabularx to make the table fit \linewidth and you've told LaTeX to make it exactly 14.2cm plus the inter-column separation. If you use tabularx, at least one of your columns should be X. Also, you shouldn't use \\ to end a line outside tabular, array etc. and you need to end the paragraph to get the line-spacing right with \Huge. – cfr Jul 22 '18 at 14:28
  • Thanks that worked for me. @cfr What would be the proper way to end the paragraph? – Rüdiger Jul 22 '18 at 15:34
  • A blank line is the usual way. Or \par sometimes in a definition, say. (These are equivalent.) – cfr Jul 22 '18 at 18:00
  • If you don't want your tabular to move or add a caption, you don't need to use a table. – John Kormylo Jul 22 '18 at 19:22
4

When you use tabularx at least one column must be of type X.

\begin{tabularx}\linewidth{p{4cm}p{.2cm}p{10cm}}

tells tabularx to adjust the X type columns so that the total table width is \linewidth, but does not provide any X type columns for it to adjust. That is, it simultaneously tells LaTeX that the table should be exactly 14.2cm plus the relevant inter-column separation.

I take it either the first or last column should be X. In the code below, I set the last this way. I've also adjusted things to get the appropriate line-spacing for the \Huge size and removed some things either not needed for the example or not doing anything at all (e.g. the \vspace in the tikzpicture).

I changed the font just because I don't have Arial.

\documentclass[a4paper,12pt,ngerman]{article}
%font encoding
\usepackage[onehalfspacing]{setspace}
\usepackage{fontspec}
\setmainfont{Noto Sans}% I don't have Arial
\usepackage[document]{ragged2e}
\usepackage[textwidth=160mm, textheight=240mm]{geometry} 
%language
\usepackage{babel}
\usepackage{lipsum}
%table format
\usepackage{tabularx}
\usepackage{float}
%Styles
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\pagenumbering{gobble}% this is a really bad idea

\definecolor{bluey}{RGB}{12,3,150}

\newcommand\Sitebar{%
  \begin{tikzpicture}[remember picture,overlay]
    \fill[lightgray]
    (current page.north west) -- ([xshift = 4cm]current page.north west) --
    ([xshift=7cm]current page.north west) --
    ([xshift=7cm]current page.south west) -- 
    (current page.south west) -- cycle;
    \draw [gray, line width = 1.5pt] ([xshift=7cm]current page.north west) --
    ([xshift=7cm]current page.south west);
  \end{tikzpicture}%
}

%header format
\newcommand\HeaderTwo{%
  \begin{tikzpicture}[remember picture,overlay]
    \fill[bluey]
    (current page.north west) -- (current page.north east) --
    ([yshift=0.5cm]current page.north east|-current page text area.north east) --
    ([yshift=1.5cm]current page.north west|-current page text area.north west) -- cycle;
  \end{tikzpicture}%
}

% left separator
\newcommand\sepLeft{%
  \vspace*{0.5cm}%
  \begin{tikzpicture}[remember picture,overlay]
    \draw [black, line width = 2pt] (-1.75,0.5) -- (3.8,0.5);
    \draw [bluey, line width = 2pt] (5.2,0.5) -- (17.5,0.5);
  \end{tikzpicture}%
}

\begin{document}
\Sitebar
\HeaderTwo
\hspace{5cm} {\bfseries\Huge\color{gray} Projektreferenzen\par}
\sepLeft % separator
\begin{table}[H]
  \begin{tabularx}{\linewidth}{ p{4cm} p{0.2cm} X}
    Very Very long text to see how big this tabular actually is && \lipsum[1]
  \end{tabularx}
\end{table}
\end{document}

output

\pagenumbering{gobble} is, I think, a very bad idea. Are you sure that you don't just want no page numbers to be shown? For that, you can use \pagestyle{empty} and/or \thispagestyle{empty} or, if really necessary, redefine \thepage to \relax or something.

  • Very very nice. Upvoted. – Sebastiano Jul 23 '18 at 8:40
1

With paracol package it is possible to write several columns in parallel and even synchronize paragraphs between columns.

Following code shows one possible appliaction of paracol environment to your example. geometry margins have been changed to reduce left and right margins. Command \columnratio defines proportion between different columns, only left column has been defined in this case (2 columns).

% !TeX program = lualatex
\documentclass[a4paper,12pt]{article}

%font encoding
\usepackage[onehalfspacing]{setspace}
\usepackage{fontspec}
\setmainfont{Arial}
\usepackage[document]{ragged2e}
\usepackage[left=8mm, right=8mm, textheight=240mm]{geometry} 
\usepackage{paracol}

%language
\usepackage[ngerman]{babel}
\usepackage{lipsum}

%table format
\usepackage{tabularx}
\usepackage{float}

%Styles
%\usepackage{tikz} % <- already loaded by `tikzpagenodes`
\usepackage{tikzpagenodes} 
\usepackage{atbegshi}
\usepackage{fancyhdr}
%\usepackage{xcolor} %<- already loaded by `tikz`
%\usepackage{lipsum} %<- duplicated

\pagenumbering{gobble}

\definecolor{bluey}{RGB}{12,3,150}

\newcommand\Sitebar{%
    \begin{tikzpicture}[remember picture,overlay]
    \fill[lightgray]
    (current page.north west) -- ([xshift = 4cm]current page.north west) --
    ([xshift=7cm]current page.north west) --
    ([xshift=7cm]current page.south west) -- 
    ([xshift=0cm]current page.south west) -- cycle;
    \draw [gray, line width = 1.5pt] ([xshift=7cm]current page.north west) --
    ([xshift=7cm]current page.south west);
    \end{tikzpicture}%
}

%header format
\newcommand\HeaderTwo{%
    \begin{tikzpicture}[remember picture,overlay]
    \fill[bluey]
    (current page.north west) -- (current page.north east) --
    ([yshift=0.5cm]current page.north east|-current page text area.north east) --
    ([yshift=1.5cm]current page.north west|-current page text area.north west) -- cycle;
    \end{tikzpicture}%
}

% left separator
\newcommand\sepLeft{%
    \vspace{0.5cm}
    \begin{tikzpicture}[remember picture,overlay]
        \hspace{1.5cm}
        \draw [black, line width = 2pt] (-1.75,0.5) -- (3.8,0.5);
        \draw [bluey, line width = 2pt] (5.2,0.5) -- (17.5,0.5);
    \end{tikzpicture}%
}

\setlength{\columnsep}{12mm}
\columnratio{.3}

\begin{document}
    \Sitebar
    \HeaderTwo
\begin{paracol}{2}
\begin{rightcolumn}
\bfseries\Huge\color{gray}Projektreferenzen\par
\end{rightcolumn}
\end{paracol}
\sepLeft
\begin{paracol}{2}
\lipsum[2]
\switchcolumn
\lipsum[1]
\end{paracol}
\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.