1

I have a heading that is made out of two minipages, one with a logo on the left and one with some text to the right. Neither of them touch the borders of the page as does the rest of the text (when using showframe package, there's a little gap between the border and whatever's in the minipage.

This is what I have:

\documentclass[11pt, a4paper]{article}

\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{showframe}

\noindent{
\begin{minipage}{0.20\textwidth}
    \vspace{-2.5pt}
    \includegraphics[width=3cm]{IMAGE}
\end{minipage}
}
\hfill
\noindent{
\begin{minipage}{0.70\textwidth}    
    \noindent{Class code and name \hfill Professor name, semester}
    
    \noindent{My name and student id number \hfill date}
\end{minipage}
}

And this is what it looks like:

There's a little gap that I'd like to get rid of. None of the other parts of the document exhibit this gap. All text touches both sides of the border.

3
  • Welcome to TeX SX! \noindent doesn't use an argument, so remove the braces. Also the second noindent is useless, since you don't start a new paragraph.
    – Bernard
    Aug 5, 2021 at 9:51
  • @WilliamA.Noble did the answer meet your requirements - do let us know
    – js bibra
    Aug 6, 2021 at 0:02
  • The braces were it. They were adding some padding around the text and image. @Bernard Could you add your suggestion as an answer? Aug 6, 2021 at 1:32

2 Answers 2

2

Look at your second minipage:

\noindent{
\begin{minipage}{0.70\textwidth}    
    \noindent{Class code and name \hfill Professor name, semester}
    
    \noindent{My name and student id number \hfill date}
\end{minipage}
}

You have the space after \end{minipage} before the final } after which you have second space. Following \par removes only single space by build-in TeX paragraph algorithm. So you can do:

\noindent{
\begin{minipage}{0.70\textwidth}    
    \noindent{Class code and name \hfill Professor name, semester}
    
    \noindent{My name and student id number \hfill date}
\end{minipage}% <- a space was here
} 

Now, you have only single space after final } and it is removed by \par. But much better is do not use irrelevant {...} prefixed by \noindent:

\noindent
\begin{minipage}{0.20\textwidth}
    \vspace{-2.5pt}
    \includegraphics[width=3cm]{example-image}
\end{minipage}
\hfill
\begin{minipage}{0.70\textwidth}
    \noindent Class code and name\hfill Professor name, semester

    \noindent My name and student id number \hfill date
\end{minipage}

Note that there was a space after first \noindent{ so your image was shifted by one space right too. Now, there is no space because the end of line is at the end of control sequence. The second \noindent was irrelevant (in horizontal mode) and \noindents inside the minipage are used without irrelevant {...}. Now, the space after \end{minipage} is only single space and it is removed by following \par (empty line generates \par and it starts paragraph building algorithm if TeX is in horizontal mode).

0

enter image description here

\documentclass[border=0.1cm]{article}


\usepackage[demo]{graphicx}
\usepackage{showframe}

\begin{document}
    \noindent
    \begin{minipage}{0.5\textwidth}
        \vspace{-2.5pt}
        \includegraphics[width=3cm]{IMAGE}
    \end{minipage}%
\hfill%
    \begin{minipage}{0.5\textwidth}    
        \noindent{Class code and name \hfill Professor name, semester}
        \noindent{My name and student id number \hfill date}
    \end{minipage}

\end{document}

OR

\documentclass[border=0.1cm]{article}


\usepackage[demo]{graphicx}
\usepackage{showframe}

\begin{document}
    \noindent
    \begin{minipage}{0.3\textwidth}
        \vspace{-2.5pt}
        \includegraphics[width=3cm]{IMAGE}
    \end{minipage}%
\hfill%
    \begin{minipage}{0.7\textwidth}    
        Class code and name \hfill Professor name, semester\\       
        My name and student id number \hfill date
    \end{minipage}

\end{document}

enter image description here

Top alignment

\documentclass[border=0.1cm]{article}


\usepackage[demo]{graphicx}
\usepackage{showframe}
\usepackage{adjustbox}
\begin{document}
    \noindent
    \adjustbox{valign=t}{\begin{minipage}{0.3\textwidth}
        \vspace{-2.5pt}
        \includegraphics[width=3cm]{IMAGE}
    \end{minipage}}%
\hfill%
    \adjustbox{valign=t}{\begin{minipage}{0.7\textwidth}    
        Class code and name \hfill Professor name, semester\\       
        My name and student id number \hfill date
    \end{minipage}}

\end{document}

enter image description here

2
  • Thank you for the answer. May I ask, what is the border=0.1cm for? Aug 6, 2021 at 1:33
  • a carry over from copy and paste -- please ignore it -- not related to your solution
    – js bibra
    Aug 6, 2021 at 3:59

You must log in to answer this question.

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