2

this is my code:

\documentclass[12pt, a4paper]{article}
 \begin{document}

\begin{table}[htpb] \centering { \caption{\small{Descrição do Requisito Funcional $02$}} \vspace{10pt} \begin{tabular}{p{6cm}|p {6cm}} \hline \multicolumn{2}{c}{RF02: Exibir nome, DRE e situação de matrícula do aluno} \ \hline \multicolumn{2}{l}{Objetivo: permitir que o usuário visualize nome, DRE e situação de matrícula do aluno} \ \hline \multicolumn{2}{l}{Pré-condições: o usuário deve estar logado no sistema} \ \hline \multicolumn{2}{l}{Pós-condições: o nome, o DRE e a situação de matrícula são exibidas} \ \hline \multicolumn{2}{l}{Prioridade (1-5): 1 (alta)} \ \hline \multicolumn{2}{l}{Trigger: o usuário seleciona o nome do aluno orientado na página principal do sistema desejando acessar suas informações} \ \hline \multicolumn{2}{l}{RNF específicos: segurança - o usuário deve estar logado no sistema} \ \hline Usuário & Sistema\ \hline $1.$ Acessa o sistema & $2.$ Solicita CPF e senha\ \hline $3.$ Informa CPF e senha & $4.$ Valida CPF e senha\ & [E1: CPF ou senha incorretos]\ \hline $5.$ Seleciona o nome do aluno orientado & $6.$ Exibe o nome completo do aluno, seu DRE e sua situação de matrícula\ \hline \multicolumn{2}{c}{[Fluxo de Exceção E1: CPF ou senha incorretos]} \ \hline &$1.$ Exibe mensagem de erro\
\hline &$2.$ Retorna ao passo $2$ do fluxo principal\ \hline \end{tabular} } \end{table
} \end{document}

this is the output: enter image description here

how can i fix this so i can see the full table?

CarLaTeX
  • 62,716
B612
  • 153
  • 6

1 Answers1

0

First off, let me encourage you to peruse the query My table doesn't fit; what are my options? and its associated answers in case you would like to familiarize yourself with a number of useful techniques related to keeping the width of the table from exceeding the width of the textblock.

Second, on to the main issue that's afflicting your two-column table. The overflow happens because even though you've defined the table to allow automatic line breaking in its individual columns, you then employ the l column type -- which does not allow for automatic line breaking -- for the header elements that span both of the underlying columns.

The fix? I suggest you replace the l column type with the p column type. The main remaining issue is to determine the usable width of the combined columns. Since the usable width of the underlying columns is 6cm and the two columns are separated by 2 bands of whitespace (in the amount of \tabcolsep each) and a vertical rule (with width \arrayrulewidth), the usable width of the combined columns equals 12cm+2\tabcolsep+1\arrayrulewidth.

I would further like to recommend that you (a) allow for hanging indentation of the material in the subcolumns and (b) omit some of the horizontal rules, especially in what amounts to the table's header, in order to make the table more readable.

enter image description here

\documentclass[12pt, a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[brazilian]{babel} % or 'portuguese'?

\usepackage{ragged2e,microtype} \usepackage{array} % for '\newcolumntype' macro % Define two new column types: % (a) for full-width columns: \newcolumntype{L}{@{} >{\RaggedRight}p{\dimexpr12cm+2\tabcolsep+1\arrayrulewidth\relax} @{}} % (b) for half-width columns: \newlength\mylen \settowidth\mylen{$4.$\space} % amount of hanging indentation \newcolumntype{P}[1]{>{\RaggedRight\hangafter1\hangindent\mylen}p{#1}}

\begin{document}

\begin{table}[htpb] \setlength\extrarowheight{3pt} % for a less-cramped look

\centering \caption{%\small % <-- why? Descrição do Requisito Funcional $02$}

\vspace{0.5\baselineskip} \begin{tabular}{@{} P{6cm} | P{6cm} @{}} \hline \multicolumn{2}{c}{RF02: Exibir nome, DRE e situação de matrícula do aluno} \ \hline \multicolumn{2}{L}{Objetivo: permitir que o usuário visualize nome, DRE e situação de matrícula do aluno} \ %\hline \multicolumn{2}{L}{Pré-condições: o usuário deve estar logado no sistema} \ %\hline \multicolumn{2}{L}{Pós-condições: o nome, o DRE e a situação de matrícula são exibidas} \ %\hline \multicolumn{2}{L}{Prioridade (1--5): 1 (alta)} \ %\hline \multicolumn{2}{L}{Trigger: o usuário seleciona o nome do aluno orientado na página principal do sistema desejando acessar suas informações} \ %\hline \multicolumn{2}{L}{RNF específicos: segurança -- o usuário deve estar logado no sistema} \[0.5ex] \hline Usuário & Sistema\ \hline $1.$ Acessa o sistema
& $2.$ Solicita CPF e senha\ %\hline $3.$ Informa CPF e senha & $4.$ Valida CPF e senha\ & [E1: CPF ou senha incorretos]\ %\hline $5.$ Seleciona o nome do aluno orientado & $6.$ Exibe o nome completo do aluno, seu DRE e sua situação de matrícula\ \hline &[Fluxo de Exceção E1: CPF ou senha incorretos] \ %\hline & $1.$ Exibe mensagem de erro\
%\hline & $2.$ Retorna ao passo $2$ do fluxo principal\ \hline \end{tabular} \end{table} \end{document}

Mico
  • 506,678
  • Don't you mean that the usable width is 12cm-2\tabcolsep-1\arrayrulewidth? – barbara beeton May 07 '23 at 13:41
  • @barbarabeeton - Because the usable width of the combined columns exceeds the simple sum of the underlying individual usable column widths (6cm each), one needs to add, not subtract, 2\tabcolsep and 1\arrayrulewidth to 12cm. :-) – Mico May 07 '23 at 15:24