4

I want to add a source address of my address like this:

Current status

But the address must start from the beginning of figure like this: Target

How can I do that? Thanks

  • You need to be a little more forthcoming in terms of how you currently display your Source: ... content. Could you provide the community with a minimal working example (MWE) that replicates your current behaviour? The solution might be as simple as using \raggedright \textbf{Source:} ... with appropriate paragraphs (empty lines or \par) in your figure environment. – Werner Jun 22 '15 at 19:46
1

Getting the code from your previous question, I add a command for stating the source to be typeset along with the image in a tabular:

\documentclass{article}

\usepackage{caption}
\usepackage{graphicx}
\usepackage{url}

\captionsetup{
  format=hang,
  justification=raggedright,
  singlelinecheck=false,
  figureposition=top,
}


\newcommand{\includegraphicswithsource}[3][]{%
  \begin{tabular}{@{}l@{}}
  \includegraphics[#1]{#2}\\
  Source: \url{#3}
  \end{tabular}%
}

\begin{document}

\begin{figure}
\centering
\captionbox{some text goes here. This text is just 
  some dummy replacement for the figure caption}{%
   \includegraphicswithsource[width=6cm]{example-image-a}{www.dummy.com}%
}

\end{figure}

\end{document}

enter image description here

3

One option is to put the image and its source text inside a varwidth (requires the varwidth package) environment:

\documentclass[twocolumn]{scrartcl}
\usepackage{graphicx}
\usepackage{varwidth}
\usepackage{url}

\newcommand\Source[1]{\par\textbf{Source:} \url{#1}\par}

\begin{document}

\begin{figure}
\centering
\caption{some text goes here. This text is just some dummy replacement for the figure caption}
\begin{varwidth}{\linewidth}
\includegraphics[width=6cm]{example-image-a}
\Source{www.dummy.com}
\end{varwidth}
\end{figure}

\end{document}

enter image description here

If you know the figure width, a simple minipage will do the job:

\documentclass[twocolumn]{scrartcl}
\usepackage{graphicx}
\usepackage{url}

\newcommand\Source[1]{\par\textbf{Source:} \url{#1}\par}

\begin{document}

\begin{figure}
\centering
\caption{some text goes here. This text is just some dummy replacement for the figure caption}
\begin{minipage}{6cm}% the width here is equal to the image width
\includegraphics[width=6cm]{example-image-a}
\Source{www.dummy.com}
\end{minipage}
\end{figure}

\end{document}
2

Here's a possibility using a \stackunder. I show two figures, the second with the boxhandler package to give the OP a similar caption format to what was presented, although it is below, rather than above the image.

\documentclass{article}
\usepackage{stackengine,lipsum,boxhandler}
\usepackage[demo]{graphicx}
\begin{document}
\lipsum[4]
\begin{figure}[ht]
\centering
\caption{Lorem imsum dolor sit amet, consectetuer adipiscing elit.  
  Aenean commodo ligula eget dolor.  Aenean massa.}
\def\stackalignment{l}
\stackunder{\includegraphics[width=3in]{demo}}{\textbf{Source:} www.dummy.com}
\end{figure}

\bxfigure[ht]
{Lorem imsum dolor sit amet, consectetuer adipiscing elit.  
  Aenean commodo ligula eget dolor.  Aenean massa.}
{\def\stackalignment{l}
\stackunder{\includegraphics[width=3in]{demo}}{\textbf{Source:} www.dummy.com}}
\end{document}

enter image description here

  • When I try to compile your code, MikTeX gives error: program can't start because Qt5WinExtras.dll is missing. All other my LaTeX files I can normally compile. Do your code require something extra for compilation? – Zarko Jun 22 '15 at 20:16
  • I just discover that source of my problem is package boxhandler. If I omit it and second example in your answer, then all works as expected. Nice solution! – Zarko Jun 22 '15 at 20:20
  • @Zarko It does not require anything extra, to my knowledge. I do not even recognize the error message as being related to LaTeX. – Steven B. Segletes Jun 22 '15 at 20:21
  • @Zarko Thank you for the clarification. I wrote boxhandler but have no Idea what could be happening to bring on the error. But I'll look around. – Steven B. Segletes Jun 22 '15 at 20:23
  • After recent MikTeX update all works! Recently it has some problems with .dll libraries etc. It seems that now all is fixed. – Zarko Jun 27 '15 at 15:35
1

How about this? I used the measuredfigure environment, from threeparttable, to have a caption of the width of the figure, and the copyrightbox, which is done to add such an information to tables/figures:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption, threeparttable}
\usepackage{copyrightbox, url}
\urlstyle{sf}
\captionsetup{format=hang}

\begin{document}

\begin{measuredfigure}
  \centering
  \caption{some text goes here. This text is just some dummy replacement for the figure caption}
  \copyrightbox[b]{
    \includegraphics[width=6cm]{sourceimg}}
  {Source: \url{www.dummy.com}}
\end{measuredfigure}

\end{document} 

enter image description here

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.