Feedback on my LaTeX code please

In summary: Some other tips include using packages and macros to keep your code organized and reusable, using comments and descriptive variable names to make your code more understandable, and breaking up long equations and proofs into multiple lines for readability. It's also important to properly format your code with indentation and line breaks to make it easier to read and debug.
  • #1
Eclair_de_XII
1,083
91
TL;DR Summary
Tried copying math proof from this forum into LaTeX. Need feedback on how to better structure it.
style:
\newcommand\func{\(f\)}
\newcommand\myset[1][math]{\ifthenelse{\equal{math}{#1}}{\(K\)}{K}}

\newcommand\diff[4]{\(|#1-#2|#4#3\)}

\newcommand\ball[3]{\diff{#1}{#2}{#3}{<}}
\newcommand\Fllab[2]{\diff{f(#1)}{f(#2)}{\epsilon}{\geq}}

\newcommand\term[2][n_k]{\({#2}_{#1}\)}

\newcommand\setdelta[1]{\(\delta=#1\)}
\newcommand\ptsinset[1]{\(x_{#1},y_{#1}\in\myset[]\)}

\newcommand\xyball[1]{\ball{x_{#1}}{y_{#1}}{\ifthenelse{#1>1}{\frac{1}{#1}}{1}}}

\newcommand\seq[2][n]{\(\{{#2}_{#1}\}\)}

\newcommand\ucontinv{there is \(\epsilon>0\) such that for any \(\delta>0\), there are points \(x,y\in \myset[]\) such that \ball{x}{y}{\delta} but \Fllab{x}{y}}

\newcommand\seqconverge[2]{There is an integer \(#1\) such that if \(n_k\geq#1: |{#2}_{n_k}-z|<\delta'\)\par}

proof:
Let \func{} be a continuous function defined on a sequentially compact set \myset. Suppose \func is not uniformly continuous. By definition, \ucontinv.

In particular, choose \setdelta{1} and find points \ptsinset{1} with the property that \xyball{1} and \Fllab{x_1}{y_1}. Now choose \setdelta{2} and then find points \ptsinset{2} with the property that \xyball{2} and \Fllab{x_2}{y_2}.

Continuing in this fashion, we obtain two sequences \seq{x}, \seq{y} with the property that for any \(\delta>0\), we can choose an integer \(N>\frac{1}{\delta}\) in order to ensure that \(|x_N-y_N|<\frac{1}{N}<\delta\).

Since \myset{} is sequentially compact, it follows that there exists a subsequence of \seq{x}, which we shall denote as \seq[n_k]{x} that converges to some point \(z \in \myset[]\). Now for each \seq[n_k]{x}, choose \seq[n_k]{y} such that \ball{x_{n_k}}{y_{n_k}}{\frac{1}{m}} where \(m\) is the index of \term{x}, \term{y} in their respective parent sequences.

This gives us a sequence \seq[n_k]{y} with the property that \(|y_{n_k}-x_{n_k}|\rightarrow0\). Moreover, since a given \term{x} gets arbitrarily close to \(z\), it follows that \term{y} must get close to \(z\) as well.

There is \(\delta'>0\) such that for all \(x\in \myset[]\), in particular the terms in the sequence constructed, with the property that whenever \ball{x}{z}{\delta'}, it follows that \ball{f(x)}{f(z)}{\frac{\epsilon}{2}}.

\seqconverge{N_1}{x}
\seqconverge{N_2}{y}

Choose \(N\equiv \sup\{N_1,N_2\}\) such that if \(n_k\geq N\):

\begin{align*}
|f(x_{n_k})-f(z)|<\frac{\epsilon}{2}\\
|f(z)-f(y_{n_k})|<\frac{\epsilon}{2}
\end{align*}

It follows that:

\begin{align*}
\epsilon&>&|f(z)-f(y_{n_k})|+|f(x_{n_k})-f(z)|\\
&\geq&|[f(z)-f(y_{n_k})]+[f(x_{n_k})-f(z)]|\\
&=&|-f(y_{n_k})+f(x_{n_k})|
\end{align*}

contrary to the assumption that \(|f(x_n)-f(y_n)|%
\nrightarrow0\) for all \(x_n,y_n\).

main:
\documentclass{minimal}

\usepackage{ifthen}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{style}

\begin{document}
\input{proof}
\end{document}
 
Physics news on Phys.org
  • #2
I see lots of latex code but not where your formatted proof is having issues.

it’s hard to proceed from what you gave us.
 
  • #3
It's not actually having any issues or errors. I actually wanted feedback on how to better structure it, which is something I admit I should have mentioned in the opening post.
 
  • #4
Your best bet is to search on Latex Best Practices and see what other experienced users say.

I found this ACM article on best practices for organizing your code.

https://www.acm.org/publications/taps/latex-best-practices

On another site, it was mentioned to use source code management like git to keep track of changes and recover from bad choices.
 

Similar threads

Back
Top