Latex gasket / edge hell

I struggled for too long with the latex table. I need a table with centered headings and body cells that contain text that can wrap around. Due to the requirement of wrapping, I use p {xxx} instead of l to indicate the width of the cells. The problem is that the contents of the cells do not remain justified, so it looks like scattered garbage. To fix this problem, I use \ flushleft for each cell. This leaves reasonable content, but puts a ton of white space above and below the contents of the cell. Is there a way to stop \ flushleft (or \ center, for that matter) in order to stop adding a plentiful amount of valid spaces?

thank

\begin{landscape}
    \centering
    % using p{xxx} here to wrap long text instead of overflowing it
    \begin{longtable}{ | p{4cm} || p{3cm} | p{3cm} | p{3cm} | p{3cm} | p{3cm} |}
        \hline
         & 
        % these are table headings.  the \center is causing a ton of whitespace as well
        \begin{center} \textbf{HTC HD2} \end{center} & 
        \begin{center} \textbf{Motorola Milestone} \end{center} & 
        \begin{center} \textbf{Nokia N900} \end{center} & 
        \begin{center} \textbf{RIM Blackberry Bold 9700} \end{center} &
        \begin{center} \textbf{Apple iPhone 3GS} \end{center} \\
        \hline
        \hline
        % using flushleft here to left-justify, but again it is causing a ton of white space above and below cell contents.
        \begin{flushleft}OS / Platform \end{flushleft}& 
        \begin{flushleft}Windows Mobile 6.5 \end{flushleft}& 
        \begin{flushleft}Google Android 2.1 \end{flushleft}& 
        \begin{flushleft}Maemo \end{flushleft}& 
        \begin{flushleft}Blackberry OS 5.0 \end{flushleft}& 
        \begin{flushleft}iPhone OS 3.1 \end{flushleft} \\           
        \hline

Edit:

. , , , :

  • \raggedright . , .
  • \raggedright , . . , .

        {Display} & 
        {\raggedright 4.3 inch, 800 x 400 resolution} & 
        {\raggedright 3.7 inch, 854 x 480 resolution} & 
        {\raggedright 3.5 inch, 800 x 480 resolution} & 
        {\raggedright 2.44 inch, 320 x 480 resolution} & 
        {\raggedright 3.5 inch, 480 x 320 resolution} \\            
        \hline
    
+3
4

, , multicolumn. , , .

\documentclass{article}

\begin{document}
\begin{table}
  \centering
  \begin{tabular}{l|p{2cm}|p{2cm}}
    \multicolumn{1}{c}{A} &
    \multicolumn{1}{c}{B} &
    \multicolumn{1}{c}{C} \\
    1 & {Some longer text} & {Some other text}\\
    2 & {Some longer text} & {Some other text}\\
    3 & {Some longer text} & {Some other text}\\
    4 & {Some longer text} & {Some other text}
  \end{tabular}
\end{table}
\end{document}
+3

, \centering \raggedright center flushleft .

, , , .

+1

@honk, , :

\ documentclass {}

\begin{document}
\begin{table}
  \centering
  \begin{tabular}{>{\raggedright}l|>{\raggedright}p{2cm}|>{\raggedright}p{2cm}|}
    \multicolumn{1}{c}{A} &
    \multicolumn{1}{c}{B} &
    \multicolumn{1}{c}{C} \\
    1 & Some longer text & Some other text\\
    2 & Some longer text & Some other text\\
    3 & Some longer text & Some other text\\
    4 & Some longer text & Some other text \\
  \end{tabular}
\end{table}
\end{document}

- , , .

+1

p , l. \hfill Somephone \hfill, \vbox to 3cm {About text}. .

0

Source: https://habr.com/ru/post/1747612/


All Articles