5

I want to put 2 different sized texts on the same line. Below are my criteria:

  • Right side is right justified and is normalsize
  • left side is left justified and is large
  • must dynamically change to fit depending on the size of the text, i.e. no predefined minipages

Currently, I am trying to use \hfill, but it is putting the right side on a new line, like shown in the picture. Any help would be greatly appreciated!

\newcommand{\resumesection}[2]{
    \bigskip
    {\color{heading}\LARGE\bfseries\MakeUppercase{#1} \hfill \color{heading}\normalsize\bfseries\vfill\RaggedRight{#2}}\\
    {\color{heading}\rule{\linewidth}{1pt}\par}\medskip
}

Output from above text, not what I am looking for

1
  • Welcome to TeX.SE! I have problems connecting your question with the code you post. Could you please explain how they are related?
    – user121799
    Commented Dec 22, 2018 at 1:00

3 Answers 3

6

Is that what is needed ?

\documentclass[12pt]{article}
\usepackage{lipsum} 
\usepackage{xcolor}
\definecolor{heading}{named}{black}
\newcommand{\resumesection}[2]{
    \bigskip\noindent
    {\color{heading}\LARGE\bfseries\MakeUppercase{#1} 
     \hfill \color{heading}\normalsize\bfseries{#2}}\\[-0.6\baselineskip]
    {\color{heading}\rule{\linewidth}{1pt}\par}\medskip
}

\begin{document}

\resumesection{Experience}{References available upon request}
\lipsum[1-2]{}
\end{document}

enter image description here

4
  • Thank you for the comment! It worked perfectly for me! How can one reduce the space between the text and that line? Commented Dec 22, 2018 at 5:04
  • @AlexTacescu the space can be reduced by providing a negative length to \\ e.g \\[ -0.5 cm] or \\[-0.6\baselineskip]. I will update my answer. Commented Dec 22, 2018 at 5:44
  • On overleaf, it is giving me an error, saying "There is no line here to end" when I copy your code exactly. Any idea why this would occur? Should I use a different Latex compiler? Commented Dec 22, 2018 at 6:24
  • @AlexTacescu I am using overleaf too and there is no error at all! So may be you should try again Commented Dec 22, 2018 at 6:31
4

You're not using the alignment correctly. Here's an option using tabularx to set the heading using \hfill between them:

enter image description here

\documentclass{article}

\usepackage{lipsum}
\usepackage{xcolor,tabularx}
\colorlet{heading}{red!65!black}

\newcommand{\resumesection}[2]{{%
  \par\bigskip
  \setlength{\arrayrulewidth}{1pt}%
  \color{heading}%
  \noindent\begin{tabularx}{\linewidth}{@{} X @{}}
    \LARGE\bfseries\MakeUppercase{#1}\hfill\normalsize\bfseries #2 \\
    \hline
  \end{tabularx}%
  \par\nobreak\medskip
}}

\begin{document}

\resumesection{Experience}{References Available upon Request}
\lipsum[1]

\end{document}
1

Maybe paracol is an option for you.

\documentclass{article}
\usepackage{paracol}
\begin{document}
\begin{paracol}{2}
\raggedright
{\large I love paracol\dots}
\switchcolumn
\raggedleft
\dots because it rhymes with crystal ball.
\switchcolumn
\raggedright
{\large All those who are hibernating in winter\dots}
\switchcolumn
\raggedleft
\dots are enjoying honey liquor and pineapple cake in summer.
\end{paracol}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .