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
1,083
90
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.
 

1. What is LaTeX and why is it used in scientific writing?

LaTeX is a typesetting language commonly used in scientific writing to create high-quality documents with complex mathematical equations and symbols. It is preferred by many scientists because it allows for precise formatting and consistent output, making it easier to create professional-looking documents.

2. How can I improve the readability and organization of my LaTeX code?

To improve the readability of your LaTeX code, it is important to use proper indentation, comments, and consistent formatting. You can also break your code into smaller, more manageable sections and use descriptive names for your variables and commands. It is also helpful to follow established LaTeX conventions and use packages and templates to make your code more organized and efficient.

3. Are there any common mistakes to avoid when writing LaTeX code?

Some common mistakes to avoid when writing LaTeX code include forgetting to use proper syntax and commands, not properly defining or using packages, and not properly managing whitespace. It is also important to proofread your code for typos and mistakes before compiling it.

4. How can I efficiently troubleshoot errors in my LaTeX code?

When encountering errors in your LaTeX code, it can be helpful to start by checking for any missing or misplaced brackets, parentheses, or commands. You can also try commenting out sections of your code to identify the source of the error. Additionally, there are many online resources and forums where you can search for solutions to common LaTeX errors.

5. How can I receive feedback on my LaTeX code to improve it?

One way to receive feedback on your LaTeX code is to share it with colleagues or peers who are familiar with the language. You can also join online communities or forums dedicated to LaTeX where you can ask for feedback and advice. Additionally, there are professional editing services available that specialize in proofreading and providing feedback on LaTeX documents.

Suggested for: Feedback on my LaTeX code please

Replies
1
Views
686
Replies
4
Views
741
Replies
3
Views
838
Replies
3
Views
1K
Replies
8
Views
998
Replies
4
Views
731
Replies
1
Views
464
Replies
1
Views
744
Replies
1
Views
2K
Back
Top