2010-05-05 56 views
14

me gustaría producir el siguiente:Centrar texto horizontalmente y verticalmente en LaTeX

 a  b 
    xxxxx xxxxx 
1 xxxxx xxxxx 
    xxxxx xxxxx 

    xxxxx xxxxx 
2 xxxxx xxxxx 
    xxxxx xxxxx 

donde los bloques de 'X son imágenes, y 'a', 'b', '1' y '2' son texto

Aquí están mis dos intentos realizados hasta ahora:

\begin{figure} 
\begin{center} 
\begin{tabular}{ccc} 
& a & b \\ 
1 & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} & 
    \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} \\ 
2 & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} & 
    \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} \\ 
\end{tabular} 
\end{center} 
\end{figure} 

que produce:

 a  b 
    xxxxx xxxxx 
    xxxxx xxxxx 
1 xxxxx xxxxx 

    xxxxx xxxxx 
    xxxxx xxxxx 
2 xxxxx xxxxx 

Y

\begin{figure} 
\begin{center} 
\begin{tabular}{m{1cm}m{6cm}m{6cm}} 
& a & b \\ 
1 & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} & 
    \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} \\ 
2 & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} & 
    \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} \\ 
\end{tabular} 
\end{center} 
\end{figure} 

que produce:

a  b 
    xxxxx xxxxx 
1 xxxxx xxxxx 
    xxxxx xxxxx 

    xxxxx xxxxx 
2 xxxxx xxxxx 
    xxxxx xxxxx 
+0

Para futuros lectores, consulte: http://tex.stackexchange.com/questions/12703/how-to-create-fixed-width-table-columns-with-text-raggedright-centered-raggedlef – Bernhard

Respuesta

12

Puede hacer un nuevo tipo de columna, o simplemente añadir >{\centering\arraybackslash} antes m{6cm} para las dos columnas de imagen.

Por ejemplo:

\newcolumntype{C}{>{\centering\arraybackslash} m{6cm} } %# New column type 
\begin{tabular}{m{1cm}CC}        %# Table with two of them 
... 

La directiva > le permite, básicamente, se inyecta el código contenido antes de cada entrada de esa columna. Necesitamos el \arraybackslash para tratar la incompatibilidad entre el entorno centering y el entorno tabular. More info can be found here.

4

Uso \dummyimage, porque no tengo im.png. Reemplácelo con \includegraphics{im.png}.

\font\dummyfont = cmr10 at 100pt 
\def\dummyimage{{\vbox to 100pt{\vfil\hbox to 100pt{\hfil\dummyfont A\hfil}\vfil}}} 

\hfil\vbox{ 
\halign{&\hfil\ $\vcenter{\hbox{#}}$\strut \ \hfil\cr 
&a&b\cr 
1&\dummyimage&\dummyimage\cr 
2&\dummyimage&\dummyimage\cr 
}} 
+0

Que es TeX, no LaTeX, ¿no? – Svante

+1

@Svante: Sí. No veo nada en la respuesta de Alexey que pueda causar problemas en Latex. –

Cuestiones relacionadas