Search code examples
latexboxoval

How to force elements to be on the same line?


I want to add skills to a sidebar of my CV created in LaTeX, I am using tcolorbox package to create an oval box around text, but each time I'm creating a new oval box the text (with box) goes to a new line. How can I force it to be added one after another in the same line?

Here is the code for the template (latex template twentysecondcv):

\documentclass[letterpaper]{twentysecondcv} % a4paper for A4
\definecolor{shadecolor}{rgb}{1,0.8,0.3}

\usepackage{times,tcolorbox}
\newtcbox{\ovalbox}{colback=gray!50!white,boxrule=0pt,arc=5pt,
  boxsep=0pt,left=4pt,right=4pt,top=2pt,bottom=2pt}

\profilepic{alice.jpeg}
\cvname{Your Name}
\cvjobtitle{about me}

\begin{document}

\aboutme{}
\contact{contact}

%----------------------------------------------------------------------------------------
%    SKILLS
%----------------------------------------------------------------------------------------

\myskills{
\ovalbox{Skill 1} 
\ovalbox{Skill2} 
\ovalbox{Skill3}
\ovalbox{Skill4}

}

\references{references document 1}

\makeprofile % Print the sidebar

%----------------------------------------------------------------------------------------
%    MAIN PAGE
%----------------------------------------------------------------------------------------

\section{About Me}

\hrulefill 

\section{Experience}

\hrulefill 

\section{Education}

\hrulefill 

\section{Courses}

\hrulefill 
\section{Other information}
\end{document} 

Solution

    • to have all the \tcboxes in the same line, add the nobeforeafter option to the definition of \ovalbox

    • if you modify the class file, it would be better to change the name as well (e.g. twentysecondcvx.cls) to avoid such confusion over different versions. [also change the first line in the .cls file accordingly]


    \documentclass[letterpaper]{twentysecondcvx} % a4paper for A4
    \definecolor{shadecolor}{rgb}{1,0.8,0.3}
    
    \usepackage{tcolorbox}
    \newtcbox{\ovalbox}{colback=gray!50!white,boxrule=0pt,arc=5pt,
      boxsep=0pt,left=4pt,right=4pt,top=2pt,bottom=2pt,nobeforeafter}
    
    \profilepic{alice.jpeg}
    \cvname{Your Name}
    \cvjobtitle{about me}
    
    \begin{document}
    
    \aboutme{}
    \contact{contact}
    
    %----------------------------------------------------------------------------------------
    %    SKILLS
    %----------------------------------------------------------------------------------------
    
    \myskills{
    \ovalbox{Skill 1} 
    \ovalbox{Skill2} 
    \ovalbox{Skill3}
    \ovalbox{Skill4}
    
    }
    
    \references{references document 1}
    
    \makeprofile % Print the sidebar
    
    %----------------------------------------------------------------------------------------
    %    MAIN PAGE
    %----------------------------------------------------------------------------------------
    
    \section{About Me}
    
    \hrulefill 
    
    \section{Experience}
    
    \hrulefill 
    
    \section{Education}
    
    \hrulefill 
    
    \section{Courses}
    
    \hrulefill 
    \section{Other information}
    \end{document} 
    

    enter image description here