I suggest the following:
This is realized using the tcolorbox
package:
\documentclass{book}
\usepackage{graphics}
\usepackage{caption}
\DeclareCaptionFormat{overlay}{\gdef\capoverlay{#1#2#3\par}}
\DeclareCaptionStyle{overlay}{format=overlay}
\usepackage[skins]{tcolorbox}
\tcbset{
caption color/.store in=\captioncolor,
caption color=white}
\newcommand{\mygraphics}[3][]{%
\tcbincludegraphics[float*,every float=\centering,blanker,finish={%
\captionsetup{skip=0pt}%
\tcbsetmacrotowidthofnode\mywidth{interior}%
\node[above,fill=\captioncolor,fill opacity=0.5,text opacity=1,
outer sep=0mm,inner sep=2mm,text width=\mywidth-4mm]
at (interior.south) {\captionof{figure}{#3}};},
#1]{#2}%
}
\begin{document}
\mygraphics[caption color=blue!50]{Wing.png}
{Many of the simple expressions in algebra can be thought of
in terms of the areas of rectangles.}
\mygraphics[width=7cm]{example-image-a}
{Many of the simple expressions in algebra can be thought of
in terms of the areas of rectangles.}
\end{document}
I made a macro \mygraphics
which takes two mandatory parameters: the name of the image file and the caption text. Further, a key list can be given as optional parameter. The keys can be any tcolorbox
keys. The image is made a float*
as was given by the OP.
In this application, the following options are especially interesting:
width
to set the width of the image (shown in the example code). The default is the complete text width.
caption color
to set the background color of the caption (show in the example code). The default is white.
floatplacement
to set the float options like htb
etc.
Update:
To scale the figure according to the natural size of included image, the hbox
option can be added. But, many pictures may become larger than the textwidth. However, to give options to the underlying \includegraphics
macro, you can use graphics options
if needed.
The following code has the hbox
option set as default. Also, the second example shows how to put a scale=0.5
option to a picture:
\documentclass{book}
\usepackage{graphics}
\usepackage{caption}
\DeclareCaptionFormat{overlay}{\gdef\capoverlay{#1#2#3\par}}
\DeclareCaptionStyle{overlay}{format=overlay}
\usepackage[skins]{tcolorbox}
\tcbset{
caption color/.store in=\captioncolor,
caption color=white}
\newcommand{\mygraphics}[3][]{%
\tcbincludegraphics[float*,every float=\centering,blanker,
hbox,% <--- the width is determined by the underlying '\includegraphics'
finish={%
\captionsetup{skip=0pt}%
\tcbsetmacrotowidthofnode\mywidth{interior}%
\node[above,fill=\captioncolor,fill opacity=0.5,text opacity=1,
outer sep=0mm,inner sep=2mm,text width=\mywidth-4mm]
at (interior.south) {\captionof{figure}{#3}};},
#1]{#2}%
}
\begin{document}
\mygraphics[caption color=blue!50]{Wing.png}
{Many of the simple expressions in algebra can be thought of
in terms of the areas of rectangles.}
\mygraphics[graphics options={scale=0.5}]{example-image-a}
{Many of the simple expressions in algebra can be thought of
in terms of the areas of rectangles.}
\end{document}
I suggest you read the provided manual more carefully; that could save you a major portion of that frustration.
\documentclass[twoside,openright,titlepage,numbers=noenddot,headinclude,
footinclude=true,cleardoublepage=empty,abstractoff,
BCOR=5mm,paper=a4,fontsize=11pt,ngerman,american,slovak%
]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{floatrow}
\floatsetup[figure]{capposition=top}
\begin{document}
\appendix
\part{Prílohy}
\chapter{Zdrojové údaje}
\begin{figure}
\ffigbox
{\rule{3cm}{3cm}}
{\caption{Kópia zoznamu básnikov z Kroeberovej knihy}}
\end{figure}
\end{document}
Best Answer
Meaningless part commented for clarity:
Explanation:
[H]
suggests that you want to use the packagehere
, forcing the position of your picture. Then[htbp]
is garbage. How we can see, your wishes 1, 2, and 3 are accomplished. Well, the first[]
was from the commentedHighligting
.Probably your image is too big. An optional parameter of
\includegraphics
scales here the picture to 0.8 of\textwidth
. The value is to be chosen, of course. This should solve your 4th problem.