[英]LaTex: Get figure caption to align with image
Thanks in advance for your help!在此先感谢您的帮助!
I know similar questions have been asked, but I cant get any of them to work.我知道有人问过类似的问题,但我无法让它们中的任何一个起作用。 I am trying to get the caption to be the same width as the image I am captioning.
我试图让标题与我正在添加的图像宽度相同。
Here is the code: it results in all of the words falling in line after the Figure title (image attached to show what it currently looks like. 1这是代码:它会导致所有单词都排在图形标题之后(附上的图片显示了它当前的样子。1
\documentclass[twoside,twocolumn]{article}
\usepackage{blindtext} % Package to generate dummy text throughout this template
\usepackage[sc]{mathpazo} % Use the Palatino font
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\linespread{1.05} % Line spacing - Palatino needs more space between lines
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage[english]{babel} % Language hyphenation and typographical rules
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt]{geometry} % Document margins
\usepackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{lettrine} % The lettrine is the first enlarged letter at the beginning of the text
\usepackage{enumitem} % Customized lists
\setlist[itemize]{noitemsep} % Make itemize lists more compact
\usepackage{abstract} % Allows abstract customization
\renewcommand{\abstractnamefont}{\normalfont\bfseries} % Set the "Abstract" text to bold
\renewcommand{\abstracttextfont}{\normalfont\small\itshape} % Set the abstract itself to small italic text
\usepackage{titlesec} % Allows customization of titles
\renewcommand\thesection{\Roman{section}} % Roman numerals for the sections
\renewcommand\thesubsection{\roman{subsection}} % roman numerals for subsections
\titleformat{\section}[block]{\large\scshape\centering}{\thesection.}{1em}{} % Change the look of the section titles
\titleformat{\subsection}[block]{\large}{\thesubsection.}{1em}{} % Change the look of the section titles
\usepackage{fancyhdr} % Headers and footers
\pagestyle{fancy} % All pages have headers and footers
\fancyhead{} % Blank out the default header
\fancyfoot{} % Blank out the default footer
\fancyhead[C]{Test} % Custom header text
\fancyfoot[RO,LE]{\thepage} % Custom footer text
\usepackage{titling} % Customizing the title section
\usepackage{hyperref} % For hyperlinks in the PDF
\usepackage{graphicx}
\graphicspath{ {./images/} }
\setlength{\droptitle}{-4\baselineskip} % Move the title up
\pretitle{\begin{center}\Huge\bfseries} % Article title formatting
\posttitle{\end{center}}
\setlength\parindent{24pt}
\usepackage{float}
\usepackage{floatrow}
\usepackage{pdfpages}
\newsavebox\mysavebox
\begin{document}
\begin{figure}[t]
\includegraphics[width=7.5cm]{img1.jpg}
\centering
\caption{Imaged tunnel slide of yeast. This image depicts how yeast cells were counted to determine sample concentrations. Small budding cells were not included in the total cell count. Note: 4× relay lens and 40× objective used. A ${1.75x10^6}$ mL volume is shown.}
\label{fig:mesh1}
\end{figure}
\end{document}
Very important: never ignore error messages.非常重要:永远不要忽略错误消息。 If an error tells you that you mustn't use
floatrow
with the float
package, don't ignore this error and remove one of the packages.如果错误告诉您不能将
floatrow
与float
package 一起使用,请不要忽略此错误并删除其中一个包。
Then if you don't want the caption to have an hanging indent, remove the hang
option from the caption
package.然后,如果您不希望标题有悬挂缩进,请从
caption
package 中删除hang
选项。
don't abuse the letter x
as multiplication symbol.不要滥用字母
x
作为乘法符号。 Use \times
instead.请改用
\times
。
have a look at the siunitx
package to get correct spacing and fonts for units看看
siunitx
package 以获得正确的间距和 fonts 单位
with 7.5cm
your image is too wide for your column, a warning in the log file will tell you this.对于
7.5cm
,您的图像对于您的列来说太宽,日志文件中的警告会告诉您这一点。 You can avoid this by using \linewidth
.您可以通过使用
\linewidth
来避免这种情况。
\documentclass[twoside,twocolumn]{article}
\usepackage{blindtext} % Package to generate dummy text throughout this template
\usepackage[sc]{mathpazo} % Use the Palatino font
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\linespread{1.05} % Line spacing - Palatino needs more space between lines
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage[english]{babel} % Language hyphenation and typographical rules
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt]{geometry} % Document margins
\usepackage[small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{lettrine} % The lettrine is the first enlarged letter at the beginning of the text
\usepackage{enumitem} % Customized lists
\setlist[itemize]{noitemsep} % Make itemize lists more compact
\usepackage{abstract} % Allows abstract customization
\renewcommand{\abstractnamefont}{\normalfont\bfseries} % Set the "Abstract" text to bold
\renewcommand{\abstracttextfont}{\normalfont\small\itshape} % Set the abstract itself to small italic text
\usepackage{titlesec} % Allows customization of titles
\renewcommand\thesection{\Roman{section}} % Roman numerals for the sections
\renewcommand\thesubsection{\roman{subsection}} % roman numerals for subsections
\titleformat{\section}[block]{\large\scshape\centering}{\thesection.}{1em}{} % Change the look of the section titles
\titleformat{\subsection}[block]{\large}{\thesubsection.}{1em}{} % Change the look of the section titles
\usepackage{fancyhdr} % Headers and footers
\pagestyle{fancy} % All pages have headers and footers
\fancyhead{} % Blank out the default header
\fancyfoot{} % Blank out the default footer
\fancyhead[C]{Test} % Custom header text
\fancyfoot[RO,LE]{\thepage} % Custom footer text
\usepackage{titling} % Customizing the title section
\usepackage{hyperref} % For hyperlinks in the PDF
\usepackage{graphicx}
\graphicspath{ {./images/} }
\setlength{\droptitle}{-4\baselineskip} % Move the title up
\pretitle{\begin{center}\Huge\bfseries} % Article title formatting
\posttitle{\end{center}}
\setlength\parindent{24pt}
%\usepackage{float}
\usepackage{floatrow}
\usepackage{pdfpages}
\newsavebox\mysavebox
\begin{document}
\begin{figure}[t]
\includegraphics[width=\linewidth]{example-image-duck}
\centering
\caption{Imaged tunnel slide of yeast. This image depicts how yeast cells were counted to determine sample concentrations. Small budding cells were not included in the total cell count. Note: 4× relay lens and 40× objective used. A ${1.75 \times 10^6}$ mL volume is shown.}
\label{fig:mesh1}
\end{figure}
\end{document}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.