Search code examples
textformatlatexcenteringsharelatex

How to center this piece of text in ShareLateX (editor) or Latex (in general)?


I am writing a resume and want to center text at the top of the document which contains my name and email details, like this

enter image description here

I used \begin{center} and \end{center} but it doesnt seem to work

Here is my code:


\begin{document}
\begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}

\vspace{-4mm}
\textbf{\LARGE Samuel Adams}
\\
 & \\  \textbf{Notsville, TX} $|$
\textbf{\phone \ \ +1 (000) 000 0000} $|$ 
\textbf{cxcx@gmail.com} $|$  \textbf{{www.linkedin.com/ffdfs}}\\

\end{tabular*}

\vspace{1 mm}

Can anyone help me center this piece of text?

This is how it looks right now. I am looking to center both lines just like we do it in word.


Solution

  • The table will be in the middle of the page once

    • you make the left and right margin the same size

    • use \noindent in front of the table to avoid it being indented as the first line of a new paragraph

    (I'm actually not sure why you use a table for this, you never use the second column...)


    \documentclass[a4paper,10pt]{article} 
    \usepackage[empty]{fullpage} 
    \usepackage{xcolor} 
    \usepackage{url} 
    \usepackage{wasysym} 
    \usepackage{hyperref} 
    \usepackage{enumitem} 
    \usepackage[utf8]{inputenc} 
    \usepackage[a4paper,bindingoffset=0.3in, left=0.5in,right=0.5in,top =0.8in,bottom=-5in, footskip=.25in]{geometry} 
    
    \begin{document}
    \noindent\begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}
    \textbf{\LARGE Samuel Adams} & \\
    \textbf{Notsville, TX} $|$ \textbf{\phone \ \ +1 (000) 000 0000} $|$ 
    \textbf{cxcx@gmail.com} $|$ \textbf{{www.linkedin.com/ffdfs}} & \\
    \hline
    \end{tabular*}
    
    \vspace{1 mm}
    \end{document}