fix this so latex on overleaf works :"\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Times New Roman}
\begin{document}
\begin{table}[h]
\centering
\caption{Một số phần mềm thiết kế giao thông phổ biến}
\begin{tabular}{|l|l|c|r|}
\hline
\textbf{Tên} & \textbf{Xuất xứ} & \textbf{Mô tả} & \textbf{Giá tiền} \
\hline
AutoCAD Civil 3D & Mỹ & Thiết kế hạ tầng giao thông, hỗ trợ BIM, mô hình hóa 3D cho các dự án đường bộ & Khoảng 11,200,000 VND/năm \
\hline
Bentley OpenRoads & Mỹ & Thiết kế chi tiết mạng lưới đường, mô hình địa hình, phân tích hạ tầng & Tùy theo tính năng sử dụng \
\hline
TransCAD & Mỹ & Quy hoạch giao thông, tích hợp GIS, tối ưu hóa tuyến đường và phân tích lưu lượng & Khoảng 4,000,000 VND/năm \
\hline
SUMO & Quốc tế & Phần mềm mô phỏng giao thông mã nguồn mở, tùy chỉnh cao, phổ biến trong nghiên cứu & Miễn phí \
\hline
\end{tabular}
\end{table}
\end{document}"
Assistant
To fix your LaTeX code on Overleaf and make it work correctly, you need to make sure you're compiling your document with XeLaTeX instead of the default pdfLaTeX. This is because you're using the fontspec package and the \setmainfont command, which require XeLaTeX or LuaLaTeX to function properly. Additionally, since you're using Unicode characters (Vietnamese), XeLaTeX handles them smoothly without extra configurations.
Here are the steps to fix your document:
Modify your preamble: Remove the inputenc package, as it's not needed (and can cause conflicts) when using XeLaTeX with fontspec. Your preamble should look like this:
latex
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
Set the compiler to XeLaTeX:
On Overleaf, click on the gear icon next to "Recompile" to open the Settings.
Under the Compiler option, select XeLaTeX from the dropdown menu.
Here is your corrected code:
latex
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}
\begin{table}[h]
\centering
\caption{Một số phần mềm thiết kế giao thông phổ biến}
\begin{tabular}{|l|l|c|r|}
\hline
\textbf{Tên} & \textbf{Xuất xứ} & \textbf{Mô tả} & \textbf{Giá tiền} \\
\hline
AutoCAD Civil 3D & Mỹ & Thiết kế hạ tầng giao thông, hỗ trợ BIM, mô hình hóa 3D cho các dự án đường bộ & Khoảng 11,200,000 VND/năm \\
\hline
Bentley OpenRoads & Mỹ & Thiết kế chi tiết mạng lưới đường, mô hình địa hình, phân tích hạ tầng & Tùy theo tính năng sử dụng \\
\hline
TransCAD & Mỹ & Quy hoạch giao thông, tích hợp GIS, tối ưu hóa tuyến đường và phân tích lưu lượng & Khoảng 4,000,000 VND/năm \\
\hline
SUMO & Quốc tế & Phần mềm mô phỏng giao thông mã nguồn mở, tùy chỉnh cao, phổ biến trong nghiên cứu & Miễn phí \\
\hline
\end{tabular}
\end{table}
\end{document}
By doing this, your document should compile correctly, and the Vietnamese characters will display properly using the Times New Roman font.
Alternative with pdfLaTeX (if you prefer not to use XeLaTeX):
If for some reason you need to compile with pdfLaTeX, you can adjust your document accordingly. Here's how:
Replace fontspec and \setmainfont: Remove these, as they are incompatible with pdfLaTeX.
Use appropriate font encoding and packages for Vietnamese:
Add \usepackage[T5]{fontenc} to support Vietnamese characters.
Load the babel package with the Vietnamese option.
Set the font to Times New Roman using the tgtermes package, which provides a clone of Times:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T5]{fontenc}
\usepackage[vietnam]{babel}
\usepackage{tgtermes} % Times font clone
\begin{document}
\begin{table}[h]
\centering
\caption{Một số phần mềm thiết kế giao thông phổ biến}
\begin{tabular}{|l|l|c|r|}
\hline
\textbf{Tên} & \textbf{Xuất xứ} & \textbf{Mô tả} & \textbf{Giá tiền} \\
\hline
AutoCAD Civil 3D & Mỹ & Thiết kế hạ tầng giao thông, hỗ trợ BIM, mô hình hóa 3D cho các dự án đường bộ & Khoảng 11,200,000 VND/năm \\
\hline
Bentley OpenRoads & Mỹ & Thiết kế chi tiết mạng lưới đường, mô hình địa hình, phân tích hạ tầng & Tùy theo tính năng sử dụng \\
\hline
TransCAD & Mỹ & Quy hoạch giao thông, tích hợp GIS, tối ưu hóa tuyến đường và phân tích lưu lượng & Khoảng 4,000,000 VND/năm \\
\hline
SUMO & Quốc tế & Phần mềm mô phỏng giao thông mã nguồn mở, tùy chỉnh cao, phổ biến trong nghiên cứu & Miễn phí \\
\hline
\end{tabular}
\end{table}
\end{document}
Note: The tgtermes package provides a free clone of Times font that works with pdfLaTeX. However, the original Times New Roman font is proprietary and not directly available in LaTeX distributions.
Summary:
For Unicode support and to use system fonts like Times New Roman, XeLaTeX is recommended.
If you need to stick with pdfLaTeX, use the appropriate font encodings and packages to support Vietnamese characters, and use a Times-like font available in LaTeX.