将 Java 字符串数组转换为 LaTeX 表
我有一个包含字符串的二维数组,并想用它们创建一个 LaTeX 表。 问题是它们可能会更长,并且在 15 个字符之后必须有换行符。假设
它是一个 2x2 数组,其中包含 {{"String11.......String11", "String21"}, {"String12.......String12.......String12.... ...", "String22......String22......"}} 那么结果应该如下所示:
\begin{tabular}{cc}
String11.......& String21//
String11 &//
\hline
String12.......&String22......//
String12.......&String22......//
String12.......&
\end{tabular}
在 Java 中是否有一种聪明的方法来进行此类转换?
I have an two dimension array that contains strings and want to create a LaTeX table with them.
The problem is that they could be longer and there has to be line breakes after 15 characters. The
Say it's a 2x2 array with contains {{"String11.......String11", "String21"}, {"String12.......String12.......String12.......", "String22......String22......"}} then the result should look like:
\begin{tabular}{cc}
String11.......& String21//
String11 &//
\hline
String12.......&String22......//
String12.......&String22......//
String12.......&
\end{tabular}
Is there a smart way to do such conversion in Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最快的方法是在表格单元格中设置 15em 文本换行,这可能是您最终寻找的解决方案:
Alternatively, you could probably find a way to make something like this work:
Doing some Google searches on the subject, I see that
\newline
within a LaTeX table doesn't work as easily as we might want it to, but you should be able to find something that works. The alternative of spanning a string across multiple rows seems like a poor solution.The quickest way is to just set up 15em text wrapping in your table's cells, which is probably the solution you're ultimately looking for:
Alternatively, you could probably find a way to make something like this work:
Doing some Google searches on the subject, I see that
\newline
within a LaTeX table doesn't work as easily as we might want it to, but you should be able to find something that works. The alternative of spanning a string across multiple rows seems like a poor solution.我不得不承认这个解决方案对我来说看起来很难看。我认为有很多语言可以用更少的代码和错误来完成这项任务。我怀疑 Perl 中大约有 10 行,J 中大约有 2 行。不过,这是我能想到的最好的:
I have to admit this solution looks ugly to me. I think there are lots of languages where this task could have been done with far less code and blundering around. I suspect it would come to about 10 lines in Perl, or 2 lines in J. Still, here's the best I was able to come up with: