首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在表(Latex)中安装长字符串?

如何在表(Latex)中安装长字符串?
EN

Stack Overflow用户
提问于 2019-08-28 13:07:27
回答 1查看 1.1K关注 0票数 0

我需要创建一个4列2行的表。

有什么帮助吗?

我试过这段代码,但它不适合所有的单词

代码语言:javascript
复制
\begin{table}[tbh]
    \centering{\scriptsize
        \begin{tabular}{p{0.2\textwidth}p{0.2\textwidth}p{0.2\textwidth}p{0.4\textwidth}}
        \toprule
        \textbf{Name}& \centering\textbf{Description} &\centering\textbf{Type of data}&\centering\textbf{Source}
        Continuum Geologico della Regione Toscana & Geologic database of Tuscany Region. Scale  1:10000 & Vector data Esri Shapefile& Tuscany Region Council http://www.regione.toscana.it/-/banche-dati-cartografiageologica\\ \hline
        DEM& Digital elevation  model. Cell size 10 meters& Raster float & Tuscany Region Council http://www.regione.toscana.it/ \\ \hline
        \bottomrule
    \end{tabular}
\end{table}

有什么帮助吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-28 14:41:05

  • 页面越窄,就越难把桌子放进去。如果允许修改页面布局,请加载例如geometry包,使页边距稍微小一点。
  • 语法\centering{...}是错误的,它是一个开关,不带参数。删除{}
  • 一张列窄、字长的表通常看起来左对齐比对齐好。
  • 不要将urls设置为普通文本,它们可能包含会导致文档崩溃的字母。相反,您应该使用来自hyperrefurl包的url宏。为了在表中启用更多的换行功能,我还推荐使用xurl包。
  • 您的代码缺少了一些\\,如果您已经使用了booktabs,那么就没有理由继续使用\hline了。使用\midrule会给你更好的间距。
代码语言:javascript
复制
\documentclass{article}

\usepackage{geometry}
\usepackage{booktabs}
\usepackage{xurl}
\usepackage{hyperref}
\usepackage{array}

\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}

\begin{table}[tbh]
    \centering
    \scriptsize
    \begin{tabular}{@{}P{0.18\textwidth}P{0.20\textwidth}P{0.12\textwidth}P{0.4\textwidth}@{}}
        \toprule
      \textbf{Name} & 
        \textbf{Description} &
            \textbf{Type of data}&
                \textbf{Source}\\
      \midrule
      Continuum Geologico della Regione Toscana & 
        Geologic database of Tuscany Region. Scale  1:10000 & 
            Vector data Esri Shapefile& 
                Tuscany Region Council \url{http://www.regione.toscana.it/-/banche-dati-cartografiageologica}\\
        \addlinespace
      DEM& 
        Digital elevation  model. Cell size 10 meters& 
            Raster float & 
                Tuscany Region Council \url{http://www.regione.toscana.it/} \\
        \bottomrule
    \end{tabular}
\end{table}


\end{document}

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57693181

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档