如何从文本文件中“按原样”导入文本并证明其正确性?

如何从文本文件中“按原样”导入文本并证明其正确性?

我想从 .txt 文件按原样导入文本,并让其自动换行和对齐。到目前为止,我所做的是:

\documentclass{article}%
\usepackage{listings}
\begin{document}
\lstset{ basicstyle=\ttfamily }
\lstinputlisting[breaklines=true]%
{./TEXTFILE.txt}
\end{document}

...我得到了类似的东西:

在此处输入图片描述

看起来不错,但我需要完全对齐!我该怎么做?这里是文本文件:

 We have three pairwise distinct values t0, t1, t2 from which we'll
 construct φ0, φ1, φ2 the Lagrange basis for degree 2 polynomials,
 associated with t0, t1, t2. Those three functions φ0, φ1 and φ2 Are 3
 polynomials of degree 2 built as follows : Here are our points t0, 
 t1, t2 the first polynomial φ0 is a degree 2 polynomial such that
 φ0(t0) = 1, φ0(t1) = 0 and φ0(t2)=0 We can draw this φ0 and we can
 even write a formula for φ0 since it is zero at t1 and t2, so we can
 write it as (t-t1)*(t-t2) and I want it to be equal to 1 at t0 so I
 divide it by (t0-t1)*(t0-t2). So we get the formula for φ0 Likewise I
 can build the polynomial φ1, degree 2 polynomial such that φ1(t0)=0
 φ1(t1)=1 φ1(t2)=0 So here is the polynomial φ1 and again we have a
 formula for φ1 which is (t-t0)*(t-t2) to get 0 at t0 and t2 and I want
 it to equal 1 at t1 so I divide it by (t1-t0)*(t1-t2). Finally we can
 build φ2 of degree 2 such that φ2(t0)=0 φ2(t1)=0 φ2(t2)=1 and we get
 an analogue formula. I now claim that those 3 functions φ0, φ1, φ2 are
 a basis for the set of polynomials of degree 2 or less. Indeed we have
 three functions in P2 the set of degree 2 polynomials. The dimension
 of the space of degree 2 polynomials is 3. Why 3 ? Because if p is a
 degree 2 polynomial, write it a0+a1*t+a2*t^2. So {1, t, t^2} is the
 canonical basis for the degree 2 polynomials. There are 3 elements in
 this basis so the dimension of P2 is 3 Hence the only thing to check
 to get that φ0, φ1, φ2 are a basis is that those three functions are
 linearly independent, so I take 3 coefficients α0, α1, α2 and I write
 the linear combination α0*φ0+α1*φ1+α2*φ2 and suppose this equals 0. I
 have to show that this implies that all coefficients α0, α1, α2 are 0.
 To show this, it suffices to take t=t0 to get α0=0 t=t1 to get α1=0
 and t=t2 to get α2=0.

请将其复制并粘贴到名为“TEXTFILE.txt”的.txt文件中以复制我的示例。

答案1

您只需输入文本

在此处输入图片描述

\documentclass{article}

\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}

\begin{document}

\def\tmp{{%
\catcode`\{=12
\catcode`\}=12
\catcode`\%=12
\catcode`\\=12
\catcode`\^=12
\catcode`\_=12
\input{textfile.txt}%
}}
\tmp
\end{document}

我在这里使用了 lualatex,使用 pdflatex 设置希腊语是可能的,但需要更多的工作。

相关内容