我想知道如何强制文本居中;我有以下代码:
\documentclass[8pt,a4paper,dvipsnames]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx,color,caption}
\usepackage{epstopdf}
\usepackage[left=2cm,right=2cm,top=1.5cm,bottom=1.5cm]{geometry}
\begin{document}
\noindent
\noindent
\begin{figure}[htp]
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[scale=0.225]{Pics/Absorcion.eps} \caption{In this case the caption is \\ too long and not being centered \\ like in second figure}
\label{fig:Absor}
\end{minipage}
\color{black}\vrule
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[scale=0.2]{Pics/Emision.eps}\caption{Caption for \\ second figure}
\label{fig:Emis}
\end{minipage}
\end{figure}\\
\noindent
\end{document}
其结果如下:
我想知道为什么没有居中,我该如何强制居中!非常感谢!
答案1
您可以使用已经使用的标题包来指定对齐方式。
我还修复了您的小页面以便它们适合一行。
\documentclass[8pt,a4paper,dvipsnames]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx,color,caption}
\usepackage{epstopdf}
\usepackage[left=2cm,right=2cm,top=1.5cm,bottom=1.5cm]{geometry}
\captionsetup{justification=centering}
\begin{document}
%NO!\noindent
%NO!\noindent
\begin{figure}[htp]
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[scale=0.225]{example-image} \caption{In this case the caption is \\ too long and not being centered \\ like in second figure}
\label{fig:Absor}
\end{minipage}%%%
{\hfill\color{black}\vrule\hfill}%
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[scale=0.2]{example-image}\caption{Caption for \\ second figure}
\label{fig:Emis}
\end{minipage}%%
\end{figure}%NO!!!!\\
%NO!\noindent
\end{document}