1

This feature is very simple. In the table I'm working on, I don't know how to align the text of columns:

  • First and second column. Left alignment, to avoid white spaces, e.g, between 15mani and 15m texts.
  • Third and four column. Right alignment, to align numbers.

\documentclass{DissertateB5}
\captionsetup{labelfont=\rmdefault, textfont=\rmdefault }
\usepackage[natbibapa]{apacite}

\begin{document}

\begin{table}
\centering
\caption{Tweets. Muestras para el análisis}
\label{tab:muestrastweets}
\begin{tabular}{p{0.3\textwidth}p{0.2\textwidth}p{0.1\textwidth}p{0.2\textwidth}}
\toprule[1.5pt]
\bf Acontecimiento & \bf Hashtags & \bf Tweets & \bf Tweets/N  \\
\midrule
Primera manifestación del movimiento 15M & 15mani, 15m, acampadasol, spanishrevolution, democraciareal & 234.145 & 2.989.123\\
Elecciones 22M & 22m, elecciones, partidos, ultimahora & 12.109 & 1.031\\
Desalojo 27M & nosnovamos, bcnsinmiedo & 1 & 414.131\\

\bottomrule[1.25pt]
\end{tabular}\par
\caption*{*N $=$ 2.507.027}
\end{table}
\end{document}

enter image description here

closed as unclear what you're asking by Werner, R. Schumacher, Henri Menke, user13907, Maarten Dhondt Dec 11 '16 at 9:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    please fix your example so that it can be run to generate the image shown ! You can't use macro parameter character # in horizontal mode. I guessed a preamble but since the guess produced errors I give up. – David Carlisle Dec 8 '16 at 14:52
  • 1
    I am not sure I understand the question. Do you want to left align the table? If so, should it still be in a table-environment? Or is it something with the text inside the table? But that is left aligned. Can you please update your question and clearly state the problem. And complement your code with the part from \documentclass to \begin{document} so we can easily copy-paste and compile directly. Then it is much easier to look for improvements. – StefanH Dec 8 '16 at 15:59
  • 1
    My crystal ball says: Add \usepackage{array} to your preamble and use m instead of p for your columns: \begin{tabular}{m{.}m{.}m{.}} – Werner Dec 8 '16 at 16:12
  • 1
    @Werner This will only change the vertical alignment. He asked for left alignment. I'd suppose something like \raggedleft. – Jan Dec 8 '16 at 16:32
  • 1
    @Jan: He also asked "to array the text", whatever that means. I'll stick with my crystal ball for now... – Werner Dec 8 '16 at 16:33
1

Some suggestions:

  • For columns 1 and 2, modify the p column type so that the material in the columns is typeset ragged-right while still allowing hyphenation

  • For columns 3 and 4, use the S column type (provided by the siunitx package).

  • Don't use a \caption* directive for the material that belongs in the table's footnote area.

  • Speaking on a purely aesthetic level, I think you're making the top and bottom rules much too thick. What's wrong with the default widths of these lines?

enter image description here

%%%\documentclass{DissertateB5}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newpxtext,newpxmath} \useosf % just to emulate look of OP's screenshot...
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage[spanish, es-tabla]{babel}
\usepackage{booktabs,siunitx,ragged2e}
\sisetup{group-separator=., 
         group-minimum-digits=4}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}

\begin{document}
\begin{table}
\centering
\caption{Tweets. Muestras para el análisis}
\label{tab:muestrastweets}
\begin{tabular}{@{}L{0.3\textwidth}
                   L{0.2\textwidth}
                   S[table-format=6.0]
                   S[table-format=7.0]@{}}
\toprule[1.5pt]  % this seems much too thick...
\bfseries Acontecimiento & \bfseries Hashtags & {\bfseries Tweets} & {\bfseries\boldmath Tweets/$N^*$}  \\
\midrule
Primera manifestación del movimiento 15M & 15mani, 15m, acampadasol, spanishrevolution, democraciareal & 234145 & 2989123\\
Elecciones 22M & 22m, elecciones, partidos, ultimahora & 12109 & 1031\\
Desalojo 27M & nosnovamos, bcnsinmiedo & 1 & 414131\\
\bottomrule[1.25pt] % not quite as extreme as the \toprule setting, but still...
\addlinespace
\multicolumn{3}{@{}l}{\footnotesize${}^*\ N=\num{2507027}$}\\
\end{tabular}
\end{table}
\end{document}
  • 1
    Thanks for all Mico! And you're right! The top and bottom rules look too thick, much better to use default values ;-) – Juan Linares Dec 10 '16 at 21:59
  • Ups..I copied the lines between ´\documentclass{article}´and ´\begin{document}´ in to the .cls document ...is it right? Or some of them must be in the preamble? And then...I copied the table but when I compiled the document all the looking of the document changed...Here is a copy of the document without packages incorporated, just with the table es.sharelatex.com/project/584c8916e473d1cf1e4bd344 – Juan Linares Dec 10 '16 at 23:18
2

Maybe this is what you are looking for:

\documentclass{scrartcl}
\usepackage{array}
\usepackage{ragged2e}
\begin{document}
\begin{tabular}{l>{\RaggedRight\hspace{0pt}}p{2cm}>{\RaggedRight\hspace{0pt}}m{2cm}>{\RaggedRight\hspace{0pt}}b{2cm}r}
  foo & long text in the first column
  & long text in the second column
  & even longer text in the third and second-last column
  & bar
\end{tabular}
\end{document}

and in result:

enter image description here

(The example was adapted from my answer to your last question.)

Bye

Jan

Not the answer you're looking for? Browse other questions tagged or ask your own question.