Last active
February 22, 2016 15:36
-
-
Save dokenzy/e473bf318fe35b0900d6 to your computer and use it in GitHub Desktop.
minipage안에 한줄씩 들어가는 문자열 중에서 제일 긴 문자열을 minipage의 너비로 삼고자 할 때, LuaTeX을 이용해서 쉽게 하는 방법
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
% http://blog.dokenzy.com/archives/2154 | |
\usepackage{luacode} | |
\begin{luacode*} | |
texs = {'PDFLaTeX', 'XeTeX', 'LuaTeX'} | |
max = 0 | |
for k, v in pairs(texs) do | |
if v:len() > max then | |
max = v:len() | |
end | |
end | |
print(max) | |
max_length = max * 0.5 .. 'cm' | |
\end{luacode*} | |
\begin{document} | |
Max length is \luaexec{tex.sprint(max_length)}.\\ | |
\vspace{1cm} | |
\hfill | |
\begin{minipage}{\luadirect{tex.print(max_length)}} | |
\luaexec{ | |
for k, v in pairs(texs) do | |
tex.sprint("".. v .."\\\\") | |
end | |
} | |
\end{minipage} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment