-
I tried to create a table with 4 columns and converted to a PDF file, but the 4th column is out of the page. How could I fix it? My code:
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 2 replies
-
@vincent7f In LaTeX, you can increase the paper width, increase the text width by decreasing the page margins, decrease the font size, or shorten the texts in the cells. |
Beta Was this translation helpful? Give feedback.
-
Furthermore, and that is perhaps the most elegant option, you could make some of the cells into fixed-width paragraphs and these could then break across several lines. However, in these cases, it is often best to escape from Markdown and produce the more difficult tables in LaTeX. |
Beta Was this translation helpful? Give feedback.
-
If you can provide a minimum working example including the LaTeX preamble, I can show you how some of the above could be implemented in your document and how they would look. |
Beta Was this translation helpful? Give feedback.
-
Dear @Witiko, Thanks for your quick response and tips. I tried your suggestion but failed. Actually, I used tabular in Latex to create a table with limited width. But Markdown is my favorite writing style, I hope to resolve this table width problem in Markdown. Then I could keep my writing in Latex with Markdown. Here is my sample. Regarding the .tex file couldn't be uploaded, so I changed it to be a .txt file.
|
Beta Was this translation helpful? Give feedback.
-
You can make the last three columns¹ into 2.75cm-wide paragraphs with line breaking. See ¹ More specifically, this will apply to all columns without the alignment specified ( |
Beta Was this translation helpful? Give feedback.
-
Dear Witiko, I can't find the different between yours and mine. Seems to be the same file. Would you mind to have a check? And could you tell me how to add the line breaking inside the Markdown? I believe the line break would be a better and simple solution for me. |
Beta Was this translation helpful? Give feedback.
-
Dear @vincent7f,
I am sorry, my mistake. I updated the source code.
There is currently no such option in the |
Beta Was this translation helpful? Give feedback.
-
Dear @Witiko, It found that tabularx could support line wrapping inside the cell. The example is as below. I think it's an elegant way to convert the Markdown table to a Latex tabularx table, because it does all the things for the writer. May I seek your help to replace the existing table with tabularx ? Thank you so much. Example: tabularx |
Beta Was this translation helpful? Give feedback.
-
There is a number of readability issues with this solution. For one, the justified text creates large spaces between words. We can easily fix this by replacing justified alignment with ragged-right alignment: \usepackage{ragged2e}
% ...
\begin{tabularx}{\linewidth}{|l|X<{\RaggedRight}|X<{\RaggedRight}|X<{\RaggedRight}|}
% ... Another potential issue is that the horizontal space is divided uniformly between the
Sure. It is a matter of taking the example table renderer from the Markdown package and modifying it a little here and there for To keep things clean, I suggest you put the code into a separate LaTeX theme file named \documentclass[a4paper, 12pt]{book}
\usepackage[theme = vincent7f/tabularx]{markdown}
\begin{document}
\begin{markdown}
| Name | Protect who/what? | Who carries? | Who is involved? |
| :--- | ---- | ---- | ---- |
| Criminal law | society | Law enforcement of federal and state governments | |
| Civial law | business | court | affected parties in business |
| Administrative law | day-to-day business of government agencies | federal agency | |
: Comparison of Criminal law, Civil law and administrative law
\end{markdown}
\end{document} ¹ Another software package, Pandoc, allows you to specify the width of a column with the number of dashes below the header (for example, |
Beta Was this translation helpful? Give feedback.
@vincent7f
There is a number of readability issues with this solution. For one, the justified text creates large spaces between words. We can easily fix this by replacing justified alignment with ragged-right alignment:
Another potential issue is that the horizontal space is divided uniformly between the
X
columns, whereas you may want to make some of the columns wider and others more narrow. That is where thep{2.75cm}
columns may be more useful than theX
columns in LaTeX. In the Markdown package, the…