Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have set margins using the geometry package (for my resume). I have put up the table but it is going beyond the margins. And, how to bring the Operating System text between the two lines? Please help!

The MWE:

\documentclass[12pt]{article}
\usepackage[left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm]{geometry}
\begin{document}
\begin{center}
\begin{tabular}{ l l }
\hline
\textbf{Operating Systems} & Windows XP, Windows 7, Windows 8 \\
& Ubuntu, Debian, Fedora \\
\hline
\textbf{Programming Languages} & C, C++, Core Java, Core Python, Basic C\#\\
\hline
\textbf{Web Technologies} & HTML5, CSS3, XML, Javascript, Node.js, PHP, JSP, ASP.NET\\
\hline
\textbf{Databases} & Oracle 10g, MySQL 5 \\
\hline
\textbf{Packages} & Netbeans 8.0, Microsoft Visual Studio 2008/2010/2012, Eclipse 5\\
\hline
\textbf{Linux} & Bash Shell Scripting
\end{tabular}
\end{center}
\end{document} 

enter image description here

share|improve this question

2 Answers 2

up vote 6 down vote accepted

This is one option that abuses multirow. Generally this shouldn't be done. But for this case it works.

\documentclass[12pt]{article}
\usepackage[left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm]{geometry}
   %\usepackage[margin=1in]{geometry}  %% this is short.
\usepackage{tabularx,multirow}
\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{>{\bfseries}lX}
\hline
\multirow{2}{*}{Operating Systems} & Windows XP, Windows 7, Windows 8,  Ubuntu, Debian, Fedora       \\
\hline
Programming Languages              & C, C++, Core Java, Core Python, Basic C\#                       \\
\hline
\multirow{2}{*}{Web Technologies}  & HTML5, CSS3, XML, Javascript, Node.js, PHP, JSP, ASP.NET        \\
\hline
Databases                          & Oracle 10g, MySQL 5                                             \\
\hline
\multirow{2}{*}{Packages}          & Netbeans 8.0, Microsoft Visual Studio 2008/2010/2012, Eclipse 5 \\
\hline
Linux                              & Bash Shell Scripting                                                                                       
\end{tabularx}
\end{center}
\end{document}

enter image description here

This is another version without abusing anything.

\documentclass[12pt]{article}
\usepackage[left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm]{geometry}
   %\usepackage[margin=1in]{geometry}  %% this is short.
\usepackage{array,calc}
\newlength{\mylen}
\setlength{\mylen}{\widthof{\textbf{Programming Languages}}}
\newcolumntype{L}{p{\dimexpr\textwidth-\mylen-4\tabcolsep\relax}}
\newcommand{\col}[1]{%       %% code stolen from egreg
  \begin{tabular}{@{}>{\raggedright}L@{}}
  \strut #1\strut
  \end{tabular}%
}
\begin{document}
\begin{center}
\begin{tabular}{>{\bfseries}ll}
\hline
Operating Systems     & \col{Windows XP, Windows 7, Windows 8,  Ubuntu, Debian, Fedora}       \\
\hline
Programming Languages & \col{C, C++, Core Java, Core Python, Basic C\#}                       \\
\hline
Web Technologies      & \col{HTML5, CSS3, XML, Javascript, Node.js, PHP, JSP, ASP.NET}        \\
\hline
Databases             & \col{Oracle 10g, MySQL 5}                                             \\
\hline
Packages              & \col{Netbeans 8.0, Microsoft Visual Studio 2008/2010/2012, Eclipse 5} \\
\hline
Linux                 & \col{Bash Shell Scripting}                                            
\end{tabular}
\end{center}
\end{document}

enter image description here

But, you will be better off using a list instead of tabular.

share|improve this answer
    
The long list of geometry options, [left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm], can be written a bit more succinctly as [margin=1in]. :-) –  Mico Aug 4 at 4:13
    
@Mico I agree. But the OP may want to keep different margins on different sides. That is why I didn't touch that. I will add a comment though. Thanks. –  Harish Kumar Aug 4 at 4:15

To force a tabular environment to occupy precisely the width of the text block without performing any calculations by hand, it's convenient to load the tabularx package and to specify the overall width of the tabularx environment as \textwidth. The package also provides a new column type named X, whose width is computed as a residual (\textwidth minus the widths of all other columns); this is what eliminates calculating column widths explicitly. In addition, it's straightforward to define a modified X column type that typesets its contents in ragged-right mode rather than in fully justified mode.

Separately, since the contents of all cells in the first column appear to be typeset in bold, it's convenient to write >{\bfseries}l instead of just l as the column specifier for the first column. That way, you needn't write \textbf explicitly in every single cell in the first column.

(These two suggestions are also used by @HarishKumar in the first of this two solutions.)

In addition, you may want to consider using the rule-drawing macros of the booktabs package -- specifically, \toprule and \bottomrule -- and dropping all other horizontal lines completely. Instead of the intermediate horizontal rules, which provide mainly visual clutter, consider simply adding a bit of extra vertical whitespace.

Incidentally, you will note that I would not adjust the vertical position of the strings "Operating Systems", "Web Technologies", and "Packages" in the first column. I think they look just fine the way they are placed by default.

enter image description here

\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{tabularx,booktabs}
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
\begin{document}

\noindent
\begin{tabularx}{\textwidth}{@{} >{\bfseries}l Y @{}}
\toprule
Operating Systems & Windows XP, Windows 7, Windows 8, Ubuntu, Debian, Fedora \\ \addlinespace
Programming Languages & C, C++, Core Java, Core Python, Basic C\#\\ \addlinespace
Web Technologies & HTML5, CSS3, XML, Javascript, Node.js, PHP, JSP, ASP.NET\\ \addlinespace
Databases & Oracle 10g, MySQL 5 \\ \addlinespace
Packages & Netbeans 8.0, Microsoft Visual Studio 2008/2010/2012, Eclipse 5\\ \addlinespace
Linux & Bash Shell Scripting\\
\bottomrule
\end{tabularx}
\end{document} 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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