![한 페이지 길이에 맞도록 테이블을 축소하는 방법은 무엇입니까?](https://rvso.com/image/286342/%ED%95%9C%20%ED%8E%98%EC%9D%B4%EC%A7%80%20%EA%B8%B8%EC%9D%B4%EC%97%90%20%EB%A7%9E%EB%8F%84%EB%A1%9D%20%ED%85%8C%EC%9D%B4%EB%B8%94%EC%9D%84%20%EC%B6%95%EC%86%8C%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
나는 이것과 비슷한 질문을 보았습니다.
그러나 페이지 너비에 맞도록 테이블 크기를 조정하고 싶지 않고(이미지로 변환하지 않고 이미 그렇게 했습니다), 테이블 높이를 줄여 두 페이지(또는 그 이상)를 차지하지 않도록 하고 싶습니다. .
다음과 같은 몇 가지 가능한 솔루션을 보았지만 longtable
그들은 내 테이블을 2개로 분할했고 나는 그것을 원하지 않습니다.
\resizebox
패키지의 를 사용하여 테이블을 이미지로 변환해야 합니까 graphicsx
? 아니면 다른 옵션이 있습니까?
답변1
\resizebox
이 명령은 패키지에서 제공되지만 을 사용하여 이미지의 긴 테이블을 강제로 변환할 필요는 없습니다 graphicx
. 테이블은 여전히 테이블입니다.
이 명령을 사용하여 크기가 조정된 테이블의 너비 및/또는 높이를 정의할 수 있습니다. 두 측정값을 모두 수정하면 글꼴이 비례적으로 줄어들지 않으므로 일반적으로 한 치수를 {!}
.
또한 세로 간격을 \arraystretch
줄여 글꼴을 최대한 줄일 수도 있고, \tiny
글꼴 비율을 눈에 띄게 변경하기 위해 다른 글꼴을 사용할 수도 있습니다.
\arraystretch
수직선은 항상 해롭지만, 이 경우에는 헤더 라인과 하단 라인을 제외하고 같은 이유로 특히 감소할 때 수평선도 마찬가지입니다 . 패키지는 booktabs
이 작업에 적합합니다. 다음과 같은 최소한의 작업 예제를 실험해보세요.
\documentclass{article}
\usepackage{graphicx,booktabs}
\begin{document}
\centering
{\tiny\renewcommand{\arraystretch}{.8}
\resizebox{!}{.35\paperheight}{%
\begin{tabular}{ccccc}
\toprule
11 & 12 & 13 & 14 & 15\\
\midrule
21 & 22 & 23 & 24 & 25\\
31 & 32 & 33 & 34 & 35\\
41 & 42 & 43 & 44 & 45\\
51 & 52 & 53 & 54 & 55\\
61 & 62 & 63 & 64 & 65\\
71 & 72 & 73 & 74 & 75\\
81 & 82 & 83 & 84 & 85\\
91 & 92 & 93 & 94 & 95\\
101 & 102 & 103 & 104 & 105\\
111 & 112 & 113 & 114 & 115\\
121 & 122 & 123 & 124 & 125\\
131 & 132 & 133 & 134 & 135\\
141 & 142 & 143 & 144 & 145\\
151 & 152 & 153 & 154 & 155\\
161 & 162 & 163 & 164 & 165\\
171 & 172 & 173 & 174 & 175\\
181 & 182 & 183 & 184 & 185\\
191 & 192 & 193 & 194 & 195\\
201 & 202 & 203 & 204 & 205\\
211 & 212 & 213 & 214 & 215\\
221 & 222 & 223 & 224 & 225\\
231 & 232 & 233 & 234 & 235\\
241 & 242 & 243 & 244 & 245\\
251 & 252 & 253 & 254 & 255\\
261 & 262 & 263 & 264 & 265\\
271 & 272 & 273 & 274 & 275\\
281 & 282 & 283 & 284 & 285\\
291 & 292 & 293 & 294 & 295\\
301 & 302 & 303 & 304 & 305\\
311 & 312 & 313 & 314 & 315\\
321 & 322 & 323 & 324 & 325\\
331 & 332 & 333 & 334 & 335\\
341 & 342 & 343 & 344 & 345\\
351 & 352 & 353 & 354 & 355\\
361 & 362 & 363 & 364 & 365\\
371 & 372 & 373 & 374 & 375\\
381 & 382 & 383 & 384 & 385\\
391 & 392 & 393 & 394 & 395\\
401 & 402 & 403 & 404 & 405\\
411 & 412 & 413 & 414 & 415\\
421 & 422 & 423 & 424 & 425\\
431 & 432 & 433 & 434 & 435\\
441 & 442 & 443 & 444 & 445\\
451 & 452 & 453 & 454 & 455\\
461 & 462 & 463 & 464 & 465\\
471 & 472 & 473 & 474 & 475\\
481 & 482 & 483 & 484 & 485\\
491 & 492 & 493 & 494 & 495\\
501 & 502 & 503 & 504 & 505\\
\bottomrule
\end{tabular}}}
\end{document}
일부는 다음을 좋아합니다.
\resizebox{!}{\textheight}{ ...}
여기서는 상자의 높이만 정의하기 때문에 텍스트 높이만큼 긴 테이블을 생성하지 않지만 별표 형식에서는 높이 + 깊이를 나타냅니다. 즉, 다음과 같습니다.
\resizebox*{!}{\textheight}{ ...}
\textheight
(위 MWE에서는 556.4pt) 만큼 긴 테이블을 만듭니다 .
동일한 패키지에서 사용할 수 있는 또 다른 명령은 graphicx
입니다 \scalebox
. 여기서 문제는 스케일링이 어떻게 되어야 하는지에 대한 아이디어를 갖고 있거나 원하는 것을 얻을 때까지 스케일링 값을 실험해야 한다는 것입니다. 이를 테스트하려면 MWE에서 \resizebox
명령을 다음과 같이 간단히 바꾸십시오.
\scalebox{3}[2.2]{...}
편집하다:귀하의 의견에 있는 "차원이 너무 큼" 오류는 명령의 문제가 아니라 테이블 디자인의 문제입니다 \resizebox
. LaTeX는 l
eft, r
ight 및 c
입력된 열 내부의 텍스트를 줄 바꿈할 수 없습니다 . 긴 텍스트가 포함된 열의 경우 환경 에서 p{width}
또는 열을 사용해야 합니다 . 또 다른 옵션은 환경의 , , 열 또는 환경 의 열 입니다 . 이러한 환경에는 첫 번째 인수로 동일한 이름의 패키지와 테이블의 전체 너비가 필요합니다. 예를 들어:m{width}
tabular
L
C
R
tabulary
X
tabularx
\usepackage{tabulary}
...
\begin{tabulary}{\linewidth}{RCLL}
...
\end{tabulary}
tabularx
다른 글꼴, 색상 및 맞춤을 사용하는 맞춤 열과 함께 사용하도록 코드를 변경했습니다 . 수직선과 대부분의 수평선을 피하기 위해 행 색상도 추가했습니다. 나머지는 패키지의 색상을 사용 booktabs
하고 \hline
. 결과는 다음과 같습니다.
\documentclass[a4paper]{article}
\usepackage{microtype}
\usepackage[margin=2.54cm]{geometry}
\usepackage{graphicx,booktabs,tabularx}
\usepackage[table]{xcolor}
\newcolumntype{R}{>{\leavevmode\color{magenta!70!black}\ignorespaces\sffamily\bfseries}p{2.5cm}}%
\newcolumntype{H}{>{\leavevmode\color{orange!30!black}\ignorespaces\raggedright\arraybackslash\sffamily}X}%
\newcolumntype{J}{>{\leavevmode\color{green!30!black}\ignorespaces\sffamily}X}%
\newcolumntype{W}{>{\leavevmode\color{blue!30!black}\ignorespaces\raggedleft\arraybackslash\sffamily}X}%
\rowcolors{2}{purple!05}{olive!05}
\begin{document}
\centering
{\resizebox*{\textwidth}{\textheight}{%
\renewcommand{\arraystretch}{2}
\begin{tabularx}{\textwidth}{RHJW}
\toprule\rowcolor{white}
& \textbf{Hibernate OGM} & \textbf{EclipseLink NoSQL} & \textbf{DataNucleus}\\\midrule
Goal & Complement JPA with NoSQL, key-value stores & Integrates in the father project main goal of providing a complete persistence solution & Being a standards compliant and efficient JPA and JDO platform\\
NoSQL and Datastores supported & Infinispan, EHCache, MongoDB & MongoDB, Oracle NoSQL, Oracle AQ, JMS, XML files & Google Big Table, MongoDB, Cassandra, Excel, OOXML, ODF, XML, HBase, AppEngine/DataStore, Neo4j, JSON, Amazon S3, GoogleStorage, LDAP, NeoDatis, db4o\\
Operations supported & Object Oriented queries (JP-QL), CRUD of entities, Polymorphic entities, Embeddable objects, Basic types (partial), Unidirectional and Bidirectional relationships (partial), Collections, Hibernate Search queries, JPA and Hibernate ORM API & Object Oriented Queries, Polymorphic entities, Basic types, Unidirectional relationships, Collections, JPA (partial), Complex hierarchical, Indexed hierarchical data, Mapped hierarchical data, CRUD operations, Embedded objects and collections, Inheritance, Subset of JP-QL and Criteria API, Denormalization & CRUD operations, Embedded objects and collections, Inheritance, Relationships (Unidirectional and Bidirectional), Queries for JP-QL, JDOQL and SQL (partial), Basic types, Joins.\\
No support for & Denormalization, Complex joins and aggregations & Joins & Aggregations? (not specified in documentation)\\
Future & High performance sequence generator, parallel key fetching, support for Map/Reduce, more NoSQL classes, better mixing of NoSQL and RDBMS & ? & JPA2.1 full feature list, Official support for Cassandra, Considering a plugin for REDIS\\
Commercial support & Red Hat & Oracle (via TopLink) & Supported by DataNucleus team\\
Documentation & Scattered, inactive forums, official documentation lacking & Bureaucratic forums, information is complete and gathered mainly in the official website & Active forums, acceptable official documentation, but the big advantage comes from user support in form of blogs and posts scattered around the Internet\\\bottomrule
\end{tabularx}}}
\end{document}