![Várias colunas com larguras diferentes – layout complexo](https://rvso.com/image/475748/V%C3%A1rias%20colunas%20com%20larguras%20diferentes%20%E2%80%93%20layout%20complexo%20.png)
Estou tendo problemas para criar um layout mais complexo que consiste em várias colunas com larguras diferentes e texto girado verticalmente.
Eu testei vários pacotes, \multicol \minipage \tabular
mas nenhum deles parecia adequado para a solução.
A questão
Esse tipo de layout é realmente viável em LaTex? Se sim, abordagem devo usar?
Responder1
Sim, isso pode ser feito. Com esforço suficiente, praticamente qualquer saída pode ser criada em LaTeX. Não sou tabular
especialista, mas incluí uma tentativa abaixo, como exemplo. Como já foi observado, esta é uma questão ampla, e um MWE seria muito útil para demonstrar precisamente o que se deseja alcançar e sob quais especificações.
\documentclass{article}
\usepackage[margin=2cm]{geometry} % prevent overfull hbox from wide table
\usepackage{graphicx} % for \rotatebox
\usepackage{colortbl} % for \cellcolor
\begin{document}
\begin{tabular}{|p{3cm}p{3cm}p{1cm}p{2cm}p{1cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}|}
\hline\multicolumn{9}{|l|}{}\\
\multicolumn{2}{|l}{\LARGE Longer longer heading line 1} & & \cellcolor[gray]{0.8}{} & & \multicolumn{4}{r|}{123-456-7}\\
\multicolumn{2}{|l}{\LARGE Longer longer heading line 2} & & \multicolumn{1}{c}{\cellcolor[gray]{0.8}{QR}} & & & & &\\[0.5cm]
28.2.2024 & Some venue & & & & & & &\\
20:00 & 100 USD & & & & & & &\\[1cm]
\multicolumn{5}{|l}{Basic ticket} & & & &\\[0.5cm]
\multicolumn{5}{|l}{Seat 24} & & & &\\
\multicolumn{5}{|l}{\tiny very tiny longer sentence. very tiny longer sentence.} & \rotatebox{90}{28.2.2024} & \rotatebox{90}{20:00} & \rotatebox{90}{Basic ticket} & \rotatebox{90}{Seat 24}\\[0.5cm]
\hline
\end{tabular}
\end{document}
Responder2
Eu me candidataria tikz
a isso. É possível completá-lo usando apenas minipage
s ou \parbox
es, mas tikz
adiciona um pouco mais de controle sobre posicionamento e alinhamento.
Se você quiser ajustar o espaçamento entre as linhas do texto, use setspace
. Em seguida, adicione uma das configurações opcionais: [doublespacing]
, [onehaldspacing]
, insira uma switch-macro, sa \onehalfspacing
ou \doublespacing
. Se precisar de ajuste fino, use \setstretch{<factor>}
o 1.0
espaçamento padrão. Ou simplesmente acrescente \vspace{}
um espaçamento vertical extra único.
Não sei se existe alguma dimensão desse ticket. Portanto, o exemplo abaixo usa alguns valores arbitrários para larguras e altura
\documentclass[margin=1cm]{standalone}
\usepackage[doublespacing]{setspace}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newlength\ticketheight
\setlength\ticketheight{6cm}
\begin{document}
\begin{tikzpicture}[
node distance = 1cm,
every node/.style = {
inner sep=0pt,
outer sep=0pt,
},
]
\node (A) {%
\parbox[t][\ticketheight][s]{7cm}{
{\LARGE\setstretch{1}%
Longer longer heading line 1
Longer longer heading line 2
\par}
\vspace{\fill}%
\begin{tabular}{@{}p{4cm} l@{}}
28.2.2024 & Some venue \\
20:00 & 100 USD
\end{tabular}
\vspace{\fill}%
Basic ticket
Seat 24
\vspace{\fill}%
{\tiny\setstretch{1}%
Much much longer sentence. Much much longer sentence.
Description at the bottom.
\par}}
};
\node [right=of A] (B) {
\parbox[t][\ticketheight]{3cm}{%
\includegraphics[width=\linewidth]{example-image}}
};
\node [right=of B] (C) {
\parbox[t][\ticketheight][s]{2cm}{
{\centering
123-456-7
\par}
\vspace{\fill}%
\raggedleft\onehalfspacing\small
\rotatebox{90}{%
\begin{tabular}[b]{@{}l@{}}
28.2.2024 \\
20:00 \\
Basic ticket \\
Seat 24
\end{tabular}}}
};
\end{tikzpicture}
\end{document}