0

I'm trying to align the minipage with the supervisor information on the left, and the minipage with the candidate information on the right. But the \RaggedRight and \RaggedLeft commands seem to have no effect. I checked that the ragged2e package is properly included and I also tried to use the basic version of LaTex \raggedright and \raggedleft but I didn't notice any changes. I don't get errors and both minipages remain aligned to the left, as I think is by default. The commands seem to have no effect, why is that?

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = pdflatex

\makebox[\textwidth]{\null\hfill\def\arraystretch{2}% % to change the spacing change this number
\begin{minipage}[t]{.5\textwidth}\RaggedRight
    \begin{tabular}[t]{@{}l@{}}
        \fixednamesfont \textbf{\thesissupervisortext} \\
        \namesfont \xmakefirstuc{\thesissupervisoronetitle}~\thesissupervisoronename~\thesissupervisoronesurname\\
        \namesfont \xmakefirstuc{\thesissupervisortwotitle}~\thesissupervisortwoname~\thesissupervisortwosurname\\
    \end{tabular}
\end{minipage}
%
\hfill
%
\begin{minipage}[t]{.5\textwidth}\RaggedLeft
\begin{tabular}[t]{@{}l@{}}
    \fixednamesfont \textbf{\thesiscandidatetext} \\
    \namesfont \thesiscandidatename~\thesiscandidatesurname
\end{tabular}
\end{minipage}\hfill\null}\\
5
  • 4
    please provide code that reproduces the problem you are asking about. What does "not work" mean, here? do you get an error or do you just not get the output that you expect? We do not know what output you expect and if we try to run the code shown we would get errors from undefined commands. If I take a guess I would guess that you forgot that you specified left aligned columns l even in the right aligned minipage. (you could simply remove the minipage they are doing nothing useful here. Mar 19, 2022 at 9:29
  • Thanks for the feedback, this was a template given from the university that's the reason of all these newcommand. I'll try to remove the minipage and see what changes.
    – user266709
    Mar 19, 2022 at 9:36
  • In a table cell different rules apply than for paragraphs. The l in {@{}l@{}} explicitly requests this cell to be left aligned. If you want it to be right aligned, change it to r. Mar 19, 2022 at 9:39
  • @MarcelKrüger you're absolutely right, that was the problem. Thank you very much!
    – user266709
    Mar 19, 2022 at 9:45
  • but as Zarko shows the RaggdLeft was working as it is intended to work and pushed thetable to the right of the minipage. so "not working" was really not a good description of the problem. Mar 19, 2022 at 12:02

3 Answers 3

1

We can't test your code fragment because all used command are undefined.

So, if I replace them with simple text and insert your minipages into \fbox (that the size of minipages and positioning of containing text are visible), both \RaggedRight and \RaggedLeft as expected. However, you can insted them tray to use \raggeright and raggedleft instructions.

MWE:

\documentclass{article}
\usepackage{ragged2e}

\begin{document}
    \begin{center}
\fbox{% remove in real document 
\begin{minipage}[t]{.45\textwidth}\RaggedRight
   \begin{tabular}[t]{@{} l @{}}
some text\\
some text\\
some text
    \end{tabular}
\end{minipage}
} % remove in real document 
%
\hfill
%
\fbox{% remove in real document 
\begin{minipage}[t]{.45\textwidth}\RaggedLeft
\begin{tabular}[t]{@{} l @{}}
some text\\
some text\\
some text
\end{tabular}
\end{minipage}
}% remove in real document 
    \end{center}
\end{document}

enter image description here

1

The commands \RaggedRight/\RaggedLeft and similar determine the alignment of regular paragraphs (which e.g. allow linebreaking). Table cells (except for the special case of the p type where table cells contain arbitrary paragraphs) generally only contain a single line which is never broken and does not follow this alignment but instead has explicit alignment specifications in the column type. This column type is given by the argument for \begin{tabular}. In your case {@{}l@{}} specifies (beside the technical @{} which influence spacing) one l type column, so a left aligned column. You can make it right aligned instead by changing the l to a r.

1

You have

\makebox[\textwidth]{%
  \null\hfill
  \begin{minipage}{0.5\textwidth}
  <some text>
  \end{minipage}
  %
  \hfill
  %
  \begin{minipage}[t]{.5\textwidth}
  <some text>
  \end{minipage}\hfill\null
}

which produces an overfull box, because of the space after the first minipage. And the \makebox is useless, by the way; the only purpose it serves it is to localize the setting to \arraystretch.

The two minipages serve no purpose either, because your aim is just to push the first tabular to the left and the second one to the right. Just use \noindent in front and \hfill between them. Try

\begingroup
\renewcommand{\arraystretch}{2}%
\noindent
\begin{tabular}[t]{@{}l@{}}
  \fixednamesfont \textbf{\thesissupervisortext} \\
  \namesfont \xmakefirstuc{\thesissupervisoronetitle} \thesissupervisoronename\ \thesissupervisoronesurname\\
  \namesfont \xmakefirstuc{\thesissupervisortwotitle} \thesissupervisortwoname\ \thesissupervisortwosurname\\
\end{tabular}\hfill
\begin{tabular}[t]{@{}l@{}}
  \fixednamesfont \textbf{\thesiscandidatetext} \\
  \namesfont \thesiscandidatename\ \thesiscandidatesurname
\end{tabular}\par
\endgroup

which would do exactly the same job as you want.

You must log in to answer this question.

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