1

Right-aligned text within the minipage environment is too far to the right; how can I align to the right but keep within the boundary so it does not go further to the right than the \rule below.

Code

% Define document class, font size
\documentclass[9pt]{extarticle}

% Tweak page margins
% Set left and right margin and compute the remaining ones
% https://www.sharelatex.com/learn/Page_size_and_margins#!#Paper_size.2C_orientation_and_margins
\usepackage{geometry}
\geometry{
    a4paper,
    total={170mm,257mm},
    left=20mm,
    top=20mm}
% --

% Disable paragraph indentation
\setlength{\parindent}{0pt}

% Multicolumn section
\usepackage{multicol}

% Do not show the section numbers
\setcounter{secnumdepth}{0}

% Load xcolor package and define colours
\usepackage{xcolor}
% \definecolor{darkcerulean}{rgb}{0.03, 0.27, 0.49}
\definecolor{linkcolour}{rgb}{0.0, 0.2, 0.4}
% --

% Define PDF metadata and link colours
\usepackage[pdfauthor={person},
            pdfcreator={vim},
        colorlinks={true}, % colour hyperlinks according to settings
        allcolors={linkcolour}
        ]{hyperref}
% --

\begin{document}  

% Place details side-by-side using minipage placeholder
% https://tex.stackexchange.com/a/157246/123504

% Minipage with 
\begin{minipage}{.5\textwidth}
    {\Large\textbf{A} \par} 
    text $\cdot$ text $\cdot$ text $\cdot$ text \\
    text
\end{minipage}
\hspace{0.5cm}
% Another minipage
\begin{minipage}{.5\textwidth}
    \begin{flushright}
        \textit{A} \href{https://www.google.com/}{This is too far to the right}
    \end{flushright}
\end{minipage}

% Draw rule spanning the text width
% Add space (https://tex.stackexchange.com/a/74354/123504)
\enspace
\rule{\textwidth}{1pt}

%  Summary section
\section{Summary}

% Multi-column summary section
\begin{multicols}{2}
    This will be in a new column, here is some text without a meaning.  This text
    should show what a printed text will look like at this place.
    If you read this text, you will get no information.  Really?  Is there
    no information?  Is there...
\end{multicols}

% Other section
\section{Something}

\end{document}

Preview

enter image description here

  • i removed the "align" tag because that's specifically for the multi-line display math environment align. – barbara beeton Dec 20 '17 at 20:06
1

Take into account the \hspace{0.5cm} between the two minipages, and add % at the end of lines, to prevent some unwanted \spaces, like this:

\begin{minipage}{.5\textwidth}
    {\Large\textbf{A} \par}
    text $\cdot$ text $\cdot$ text $\cdot$ text \\
    text
\end{minipage}%
\hspace{0.5cm}%
% Another minipage
\begin{minipage}{\dimexpr.5\textwidth-0.5cm}
    \begin{flushright}
        \textit{A} \href{https://www.google.com/}{This is too far to the right}
    \end{flushright}
\end{minipage}

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.