3

I'm trying to get both elements, one centered, one flushed right on the same horizontal line. I've tried

\begin{center} stuff \end{center} \hfill more stuff

But "more stuff" would appear on another line instead. Thanks.

2
  • I have not understood much. Could you please add your code or an image at least for me?
    – Sebastiano
    Jul 30, 2018 at 15:23
  • Sorry, I'm posting from my phone. I'll edit it so it's clearer tomorrow when I get back to my PC. Jul 30, 2018 at 15:25

4 Answers 4

7

A variant which saves having to guess box widths:

\documentclass{article}
\usepackage[showframe]{geometry}

\begin{document}

\noindent
\makebox[\linewidth]{\hfill \fbox{this one is centred}\hfill \llap{and that flushright}}

\end{document} 

enter image description here

1
  • And how to get rid of the border around the central box? Oct 25, 2018 at 5:09
9

If the text elements are short, you could divide the line into several boxes:

\documentclass{article}

\begin{document}

\noindent
\makebox[.32\textwidth][l]{}%
\hfill%
\makebox[.32\textwidth][c]{centred}%
\hfill%
\makebox[.32\textwidth][r]{right}%


\end{document}
9
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\noindent\mbox{}\hfill centered stuff\hfill\mbox{}\makebox[0pt][r]{right}

\lipsum[1]

\end{document}

enter image description here

4

Also,

\documentclass{article}
\usepackage{showframe} % for the frames, can be deleted
\begin{document}

\noindent \rule{.5\linewidth}{0pt}\makebox[0pt]{Center} \hfill Right

\end{document}

enter image description here

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