3

I m a beginner with LaTex and I don't really understand how to align an FBox to the left with an image inside and some text to the right.

Current implementation without boxing:

\noindent\begin{minipage}{0.8\textwidth}
   \includegraphics[width = 0.5\linewidth]{graph_southampton.PNG}
\end{minipage}

\hfill

\begin{minipage}{0.9\textwidth}\raggedleft

Yesasd asdjkasdk jakdsajkd\\
alsdjaojzxkc \\
asdjkasm

\end{minipage}

Output:

enter image description here

As you may notice they are not properly aligned, I just sent you a bit from what I have before and after to get a glimpse of my page format.

Now with Boxing

\noindent\fbox{ 

    \begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
        \lefting
        \includegraphics[width = 0.5\linewidth]{graph_southampton.PNG}
    \end{minipage}

    \hfill

    \begin{minipage}{0.001\textwidth}

        asdaksdaskdl

    \end{minipage}

}

Output

enter image description here

The box size is perfect but the text outruns the boundaries.

Could you please help me with some suggestions on both cases?

  • Welcome to TeX SX! What is the \lefting command? – Bernard May 12 '19 at 13:31
  • @Bernard Oh..Don't mind that, I was just playing around thinking that \lefting is the same as begin{left} -> end{left} – user181475 May 12 '19 at 13:34
4

an empty line starts a new paragraph

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\noindent
\begin{minipage}{0.6\textwidth}
\fbox{\includegraphics[width=\linewidth]{tiger}}
\end{minipage}
\hfill
\begin{minipage}{0.35\textwidth}\raggedleft     
        Yesasd asdjkasdk jakdsajkd\\
        alsdjaojzxkc \\
        asdjkasm
\end{minipage}

\end{document}

enter image description here

For an image with a caption use

\documentclass{article}
\usepackage{hvfloat}
\begin{document}

\hvFloat[capPos=right,capVPos=bottom,objectFrame]{figure}%
   {\includegraphics[width=0.6\linewidth]{tiger}}%
   {The caption of the figure which is on the right bottom
    of the page.}%
   {fig-label}

\end{document}

enter image description here

|improve this answer|||||
  • Thank you, this worked fine but why mine didn't? – user181475 May 12 '19 at 13:42
  • If I want to add a caption to the image, should I use begin{figure} instead of just \includegraphics – user181475 May 12 '19 at 13:46
  • As I already wrote: An empty line starts a new paragraph, so your \hfill is useless. See edited answer for a caption. – user187802 May 12 '19 at 13:54
3

This is probably the simplest possible code, with the valign key from adjustbox (and no blank lines):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[export]{adjustbox}
\usepackage{graphicx, xcolor}
\usepackage{caption} 


\begin{document}

Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.\bigskip

\noindent\fbox{\parbox{0.5\linewidth}{\includegraphics[width =\linewidth, valign=c]{LaDormeuse}\captionof{figure}{Toyen, La Dormeuse (1937)}}} \hfill asdaksdaskdl


 \end{document}

enter image description here

|improve this answer|||||
  • And how would you put caption, I mean inside the FBox. – user181475 May 12 '19 at 14:01
  • \noindent\fbox{\includegraphics[width = 0.5\linewidth, valign=c]{graph_southampton.PNG}}\hfill \begin{minipage}{0.40\textwidth}\centering The picture on the left represents \\ a \textcolor{blue}{graph}. The \textcolor{blue}{source} point is \\ corresponds to Southampton whereas \\ the \textcolor{blue}{destinations} are the other cities. \newline The edges are also labeled with the shortest path between the cities. \end{minipage} For this code I get a big white space above my text. – user181475 May 12 '19 at 14:06
  • For men the minipage is vertically centred w.r.t. the image. For the caption, I'll post a solution in a moment. – Bernard May 12 '19 at 14:12
  • What do you suggest me to do in order to get rid of that big white space ? Is it because of that valign=c. Thank you! – user181475 May 12 '19 at 14:17
  • Try valign=tfor include graphics and also write \begin{minipage[t]{0.40\textwidth}. But maybe it is due to a blank upper part in your graphic file. – Bernard May 12 '19 at 14:26

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.