테이블의 행 세로 맞춤 변경

테이블의 행 세로 맞춤 변경

다른 행에 대한 셀의 수직 정렬을 변경하는 테이블을 생성하려고 합니다. 지금은 모든 열이 가운데 정렬되도록 테이블을 설정했습니다. 그러나 마지막 두 행을 위쪽에 수직으로 정렬하고 중앙 정렬 대신 왼쪽 정렬(예: \raggedright대신 \centering)을 지정하고 싶습니다. 혹시 이렇게 할 수 있는 방법이 있는지 궁금합니다.

나는 TeX을 처음 접했기 때문에 내 코드가 그다지 깔끔하지 않을 수도 있다는 점을 이해합니다! 도움을 주시면 감사하겠습니다!

내 코드는 다음과 같습니다.

\documentclass[12pt,oneside]{report}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,top=2cm,bottom=2cm,left=4cm,right=2cm]{geometry}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{natbib}
\bibliographystyle{agsm}
\usepackage{fixltx2e}
\usepackage{textcomp}
\usepackage[UKenglish]{isodate}
\usepackage{enumitem}
\usepackage[titletoc]{appendix}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage[version=3]{mhchem}
\usepackage[labelfont=bf]{caption}
\linespread{1.3}

\begin{center}
\scriptsize
\begin{longtable}[width=1\textwidth]{>{\raggedright}m{3.2cm}>{\centering}m{1.8cm}>{\centering}m{1.8cm}>{\centering}m{1.8cm}>{\centering}m{1.8cm}>{\centering\arraybackslash}m{1.8cm}} \toprule[0.03cm]
\textbf{Property} & \textbf{Methane} & \textbf{Carbon Dioxide} & \textbf{Carbon Monoxide} & \textbf{Hydrogen Sulphide} & \textbf{Hydrogen}\\ \midrule[0.03cm] \endhead
Chemical Symbol & CH\textsubscript{4} & CO\textsubscript{2} & CO & H\textsubscript{2}S & H\textsubscript{2}\\
Molecular Weight & 16 & 44 & 28 & 34 & 2\\
Melting Point (\textdegree C) & -184 & \multirow{2}{*}{\parbox{1.8cm}{\centeringSublimes at -78.5}} & -205 & -85 & -259.14\\
Boiling Point (\textdegree C) & -164 &  & -191 & -61 & -252.87\\ \midrule[0.01cm]
Density (kg/m\textsuperscript{3}) & 0.71 & 1.98 & 1.25 & 1.53 & 0.085\\
Solubility in H\textsubscript{2}O at STP (mg/l) & 25 & 1,450 & 21.4 & 4,100 & \parbox{1.8cm}{1.62 at 21\textdegree C}\\
Viscosity (Ns/m\textsuperscript{2}) & 1.03$\times$10\textsuperscript{-5} & 1.4$\times$10\textsuperscript{-5} & 1.66$\times$10\textsuperscript{-5} & 1.0$\times$10\textsuperscript{-5} & 8.7$\times$10\textsuperscript{-6}\\
Diffusion Coefficient in Air (m\textsuperscript{2}/s at STP) & 1.5$\times$10\textsuperscript{-5} & 1.39$\times$10\textsuperscript{-5} & \parbox{1.8cm}{\centering 1.96$\times$10\textsuperscript{-5} at 9\textdegree C} & 1.76$\times$10\textsuperscript{-5} & 6.1$\times$10\textsuperscript{-5}\\ \midrule[0.01cm]
Physical Description and Attributes & Colourless, odourless and flammable gas. Important greenhouse gas. & Colourless, odourless and toxic gas. Important greenhouse gas. & Colourless, toxic, odourless and flammable gas. & Colourless, flammable and toxic gas. Rotten eggs odour at low concentration $<$ 1 ppm. Odourless at concentration $>$ 50 ppm due to anaesthesia of olfactory sense. & Colourless, odourless and flammable gas.\\ \midrule[0.01cm]
Formation & Anaerobic degradation of organic material. & Aerobic and anaerobic degradation of organic materials, action of acid water in carbonate rocks and respiration of soil bacteria. & \ce{SO4^2-}-reducing bacteria obtain energy by oxidising organic matter or H\textsubscript{2} with sulphates and produce H\textsubscript{2}S. Happens in low-O\textsubscript{2} environments (e.g. standing water). Other anaerobic bacteria produce H\textsubscript{2}S by digesting amino acids containing \ce{SO4^2-}. & Incomplete combustion of organic materials. In landfill waste can also be produced by the reduction of CO\textsubscript{2} by nascent H\textsubscript{2}. & Chemical reaction between water and finely divide metal (e.g. Al) in the ground.\\ \bottomrule[0.03cm]
\caption{Chemical and Physical Properties of Hazardous Ground Gases}
\label{tab:chemicalandphysicalproperties}
\end{longtable}
\end{center}

답변1

각각에 대해세포다시 조정하려는 행 내에서 다음을 사용하십시오.

\multicolumn{1}{p{<len>}}{\raggedright <stuff>}

이렇게 하면 수직 정렬이 위쪽으로, 수평 정렬이 로 조정됩니다 \raggedright. 고정 너비 p열은 기본적으로 상단에 앵커 포인트를 설정합니다.

여기에 이미지 설명을 입력하세요

  ...
  \multicolumn{1}{p{3.2cm}}{Formation} & 
  \multicolumn{1}{p{1.8cm}}{\raggedright 
    Anaerobic degradation of organic material.} & 
  \multicolumn{1}{p{1.8cm}}{\raggedright
    Aerobic and anaerobic degradation of organic materials, 
    action of acid water in carbonate rocks and respiration of soil bacteria.} & 
  \multicolumn{1}{p{1.8cm}}{\raggedright
    \ce{SO4^2-}-reducing bacteria obtain energy by oxidising organic matter or \ce{H2} 
    with sulphates and produce \ce{H2S}. Happens in low-\ce{O2} environments (e.g.\ 
    standing water). Other anaerobic bacteria produce \ce{H2S} by digesting amino acids 
    containing \ce{SO4^2-}.} & 
  \multicolumn{1}{p{1.8cm}}{\raggedright
    Incomplete combustion of organic materials. In landfill waste can also be produced 
    by the reduction of \ce{CO2} by nascent \ce{H2}.} & 
  \multicolumn{1}{p{1.8cm}}{\raggedright
    Chemical reaction between water and finely divide metal (e.g. Al) in the ground.} \\
  \bottomrule[0.03cm]
  \caption{Chemical and Physical Properties of Hazardous Ground Gases}
\end{longtable}

열이 좁은 경우 다음을 사용하는 것이 좋습니다.ragged2e\RaggedRight.

여담이지만... 일관성 있게 사용하세요.mhchem.

답변2

일반 TeX 솔루션은 다음과 같습니다. 이를 LaTeX 솔루션과 비교할 수 있습니다.

{\parindent=0pt \everymath={\rm}
 \emergencystretch=2em \raggedright
 \def\midrule{\noalign{\smallskip\hrule\medskip}}
 \def\e{\unskip\vrule depth7pt width0pt}
 \def\dd{\vskip-2pt\relax}

\halign{\quad\vtop{\hsize=3.2cm #\e}\quad&&\vtop{\hsize=1.8cm #\e}\quad\cr
%
\midrule
\bf\dd Property & \bf\dd Methane & \bf Carbon Dioxide &
\bf Carbon Monoxide & \bf Hydrogen Sulphide & \bf Hydrogen\cr
\midrule
Chemical Symbol  &\hfil $CH_4$ &\hfil $CO_2$ &\hfil CO &\hfil $H_2S$ &\hfil $H_2$\cr
Molecular Weight &\hfil 16 &\hfil 44 &\hfil 28 &\hfil 34 &\hfil 2\cr
Melting Point ($^\circ$C) &\hfil $-184$ &\hfil $-200$ &\hfil $-205$ &\hfil $-85$ &\hfil $-259.14$\cr
\midrule
Physical Description and Attributes &
Colourless, odourless and flammable gas. Important greenhouse gas. &
Colourless, odourless and toxic gas. Important greenhouse gas. &
Colourless, toxic, odourless and flammable gas. &
Colourless, flammable and toxic gas. Rotten eggs odour at low
   concentration $<$ 1 ppm. Odourless at concentration $>$ 50 ppm due to
   anaesthesia of olfactory sense. &
Colourless, odourless and flammable gas.\cr
\midrule
Formation &
Anaerobic degradation of organic material. &
Aerobic and anaerobic degradation of organic materials,
   action of acid water in carbonate rocks and respiration of soil bacteria. &
$SO_4^{2-}$-reducing bacteria obtain energy by oxidising organic matter
   or $H_2$ with sulphates and produce $H_2S$. Happens in
   low-$O_2$ environments (e.g. standing water). Other anaerobic
   bacteria produce $H_2S$ by digesting amino acids containing
   $SO_4^{2-}$. &
Incomplete combustion of organic materials. In landfill waste
   can also be produced by the reduction of $CO_2$ by nascent $H_2$. &
Chemical reaction between water and finely divide metal (e.g. Al) in the ground.\cr
\midrule}
}

\bye

테이블

설명: 좁은 열은 매우 보기 좋지 않지만 이는 과제의 일부입니다.

답변3

다음은 패키지를 사용하는 솔루션입니다 ( 의 ltablex기능을 추가합니다 . tabularx를 사용하면 열이 약간 더 넓어집니다. 또한 (정지된 컨텍스트에서 하이픈을 사용하기 위해) 단위와 숫자의 올바른 조판을 로드했습니다 . 명령 및 과학적 표기법에 대한 약어 사용 가능성 명령( 패키지)을 사용하면 열 머리글의 공통 형식을 사용할 수 있습니다. 마지막으로 명령을 체계적으로 사용하여 간단한 화학 화합물을 조판했습니다.longtabletabularxragged2esinuitx\si, \SI\num\theadmakecell\cemhchem

\documentclass[12pt,oneside]{report}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,top=2cm,bottom=2cm,left=4cm,right=2cm]{geometry}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{natbib}
\bibliographystyle{agsm}
\usepackage{fixltx2e}
\usepackage[UKenglish]{isodate}
\usepackage{enumitem}
\usepackage[titletoc]{appendix}
\usepackage{ragged2e}
\usepackage{ltablex}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}>{\hsize=.95\hsize}X}
\newcolumntype{Z}{>{\raggedright\arraybackslash}>{\hsize=1.25\hsize}X}
\usepackage{array}
\setlength\extrarowheight{1pt}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{booktabs}
\setlength\aboverulesep{4pt}
\usepackage[version=3]{mhchem}
\usepackage[labelfont=bf, font = footnotesize]{caption}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadalign{lc}
\renewcommand\cellalign{lc}
\usepackage{siunitx}
\newcommand\celsius{\si{\degreeCelsius}}

\begin{document}

\begin{center}
\scriptsize\setlength\tabcolsep{4pt}
\begin{tabularx}{\linewidth}{Z*{5}{Y}}
\toprule[0.03cm]
\textbf{Property} &\thead{Methane} &\thead{Carbon\\ Dioxide} &\thead{Carbon\\ Monoxide} &\thead{Hydrogen\\ Sulphide} &\thead{Hydrogen}\\
\midrule[0.03cm]
 \endhead
Chemical Symbol & \ce{CH4} & \ce{CO2} & CO & \ce{H2S} & \ce{H2}\\
Molecular Weight & 16 & 44 & 28 & 34 & 2\\
Melting Point (\celsius) &\num{-184} & \multirowcell{2}{Sublimes at\\ \num{-78.5}} &\num{-205} &\num{-85} & \num{-259.14}\\
Boiling Point (\celsius) &\num{-164} & &\num{-191} &\num{-61} & \num{-252.87}\\
\cmidrule(lr){1-6}
Density (\si{kg/m³ }) & 0.71 & 1.98 & 1.25 & 1.53 & 0.085\\
Solubility in \ce{H2O} at STP (\si{mg/l}) & 25 & 1,450 & 21.4 & 4,100 & \parbox{1.8cm}{1.62 at \SI{21}{\celsius}} \\%
Viscosity (\si{Ns/m²}) & \num{1.03e-5} & \num{1.4e-5} & \num{1.66e-5} & \num{1.0e-5} & \num{8.7e-6} \\
Diffusion Coefficient in Air (\si{m² /s} at STP) & \num{1.5e-5} & \num{1.39e-5} & \parbox{1.8cm}{\centering \num{1.96e-5} at \SI{9}{\celsius}} & \num{1.76e-5} & \num{6.1e-5} \\
\cmidrule(lr){1-6}
Physical Description and Attributes & Colourless, odourless and flammable gas.

Important greenhouse gas.
& Colourless, odourless and toxic gas.

Important greenhouse gas.
& Colourless, toxic, odourless and flammable gas.
& Colourless, flammable and toxic gas.

Rotten eggs odour at low concentration \mbox{$<$ 1\,ppm}. Odourless at concentration \mbox{$>$ 50\,ppm} due to anaesthesia of olfactory sense.
& Colourless, odourless and flammable gas.\\
\cmidrule(lr){1-6}
Formation & Anaerobic degradation of organic material. & Aerobic and anaerobic degradation of organic materials, action of acid water in carbonate rocks and respiration of soil bacteria. & \ce{SO4^2-}\mbox{-reducing} bacteria obtain energy by oxidising organic matter or \ce{H2} with sulphates and produce \ce{H2S}.

Happens in low-\ce{O2} environments (e.g. standing water).

Other anaerobic bacteria produce \ce{H2S} by digesting amino acids containing \ce{SO4^2-}.
& Incomplete combustion of organic materials.

In landfill waste can also be produced by the reduction of \ce{CO2} by nascent \ce{H2}.
& Chemical reaction between water and finely divide metal (e.g. Al) in the ground.\\
\bottomrule[0.03cm]
\end{tabularx}
\captionof{table}{Chemical and Physical Properties of Hazardous Ground Gases}
\label{tab:chemicalandphysicalproperties}
\end{center}

\end{document} 

여기에 이미지 설명을 입력하세요

관련 정보