긴 텍스트가 포함된 운송 테이블을 만드는 방법

긴 텍스트가 포함된 운송 테이블을 만드는 방법

이 운송 테이블을 테이블의 문장과 크기 사이에 맞도록 개선하는 데 도움을 줄 수 있는 사람이 있습니까?

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

다음과 같아야 합니다.

원하는 테이블 형태

운송 테이블용 라텍스 코딩입니다.참조. 미리 감사드립니다.

\documentclass{article}

\usepackage{array}
\usepackage{multirow}
\usepackage{multicol}

\usepackage{rotating}
\usepackage{tabularx}
\newcommand{\STAB}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}

\newcolumntype{C}{@{}c@{}}
\newcommand{\bottombox}[1]{\makebox[1em][r]{#1}\hspace*{\tabcolsep}\hspace*{1em}}%
\newcommand{\innerbox}[2]{%
    \begin{tabular}[b]{c|c}
        \rule{1em}{0pt}\rule[-1ex]{0pt}{1ex} & \makebox[1em]{#2} \\\cline{2-2}
        \multicolumn{2}{r}{{#1}\hspace*{1\tabcolsep}\hspace*{1em}\rule[-1ex]{0pt}{1ex}}
\end{tabular}}
\renewcommand{\arraystretch}{1}

\begin{document}
    \begin{table} [h]
        \centering
        \resizebox{\columnwidth}{!}
        {\begin{tabular}{|c|c|C|C|C|c|}
                \hline
                \multicolumn{2}{|c}{\multirow{2}{*}{From $ \backslash $ To}} & \multicolumn{3}{|c|}{Destinations} & \multirow{2}{*}{Supply} \\ \cline{3-5}
                \multicolumn{2}{|c|}{} & Sales Outlet H & Sales Outlet I & Sales Outlet J & \\ \hline
                \multirow{3}{*}{\STAB{\rotatebox[origin=c]{90}{Sources}}} & Warehouse A & \innerbox{}{\$(6,8,10,12)} & \innerbox{}{\$(5,7,9,11)} & \innerbox{}{\$(2,4,6,8)} & (15,20,30,35) \\ \cline{2-6}
                & Warehouse B & \innerbox{}{\$(3,5,7,9)} & \innerbox{}{\$(5,7,9,11)} & \innerbox{}{\$(1,3,5,7)} & (25,30,40,45) \\ \cline{2-6}
                & Warehouse C & \innerbox{}{\$(4,6,8,10)} & \innerbox{}{\$(3,5,7,9)} & \innerbox{}{\$(6,8,10,12)} & (30,35,45,50) \\ \hline
                \multicolumn{2}{|c|}{Demand} & (15,25,35,45) & (10,20,30,40) & (30,40,50,60) & \\ \hline
        \end{tabular}}
    \end{table}
\end{document}

답변1

그림에서 볼 수 있듯이 모든 내부 상자의 너비가 동일하기를 원한다고 가정합니다. 그러나 이는 LaTeX에서 수행하기 매우 어렵습니다(불가능하지는 않지만). 두 번 실행됩니다. 그래서 저는 쉬운 방법을 선택했습니다. 나는 이것에 대한 길이가 있습니다 \innerboxwidth. 내 솔루션에서 했던 것처럼 가장 넓은 항목의 너비로 초기화해야 합니다.

그건 그렇고, 중앙에 더 잘 맞기 때문에 \multirowfor를 5로 변경했습니다.Sources

\documentclass{article}

\usepackage{array}
\usepackage{multirow}
\usepackage{multicol}

\usepackage{rotating}
\usepackage{tabularx}
\usepackage{array}
\newcommand{\STAB}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}

\newcolumntype{C}{@{}c@{}}
\newcommand{\bottombox}[1]{\makebox[1em][r]{#1}\hspace*{\tabcolsep}\hspace*{1em}}%
\newlength{\innerboxwidth}
\settowidth{\innerboxwidth}{\$(6,8,10,12)}% widest entry
\newcommand{\innerbox}[2]{%
    \begin{tabular}[c]{c|>{\centering\arraybackslash}p{\innerboxwidth}}
        \rule{1em}{0pt} & {#2} \\\cline{2-2}
        \multicolumn{2}{r}{{#1}\hspace*{1\tabcolsep}\hspace*{1em}\rule[-1ex]{0pt}{1ex}}
\end{tabular}}
\renewcommand{\arraystretch}{1}

\begin{document}
    \begin{table} [h]
        \centering
        \resizebox{\columnwidth}{!}
        {\begin{tabular}{|c|c|C|C|C|c|}
                \hline
                \multicolumn{2}{|c}{\multirow{2}{*}{From $ \backslash $ To}} & \multicolumn{3}{|c|}{Destinations} & \multirow{2}{*}{Supply} \\ \cline{3-5}
                \multicolumn{2}{|c|}{} & Sales Outlet H & Sales Outlet I & Sales Outlet J & \\ \hline
                \multirow{5}{*}{\STAB{\rotatebox[origin=c]{90}{Sources}}} & Warehouse A & \innerbox{}{\$(6,8,10,12)} & \innerbox{}{\$(5,7,9,11)} & \innerbox{}{\$(2,4,6,8)} & (15,20,30,35) \\ \cline{2-6}
                & Warehouse B & \innerbox{}{\$(3,5,7,9)} & \innerbox{}{\$(5,7,9,11)} & \innerbox{}{\$(1,3,5,7)} & (25,30,40,45) \\ \cline{2-6}
                & Warehouse C & \innerbox{}{\$(4,6,8,10)} & \innerbox{}{\$(3,5,7,9)} & \innerbox{}{\$(6,8,10,12)} & (30,35,45,50) \\ \hline
                \multicolumn{2}{|c|}{Demand} & (15,25,35,45) & (10,20,30,40) & (30,40,50,60) & \\ \hline
        \end{tabular}}
    \end{table}
\end{document}

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

관련 정보